[31420] in Perl-Users-Digest
Perl-Users Digest, Issue: 2672 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 12 18:09:41 2009
Date: Thu, 12 Nov 2009 15:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 12 Nov 2009 Volume: 11 Number: 2672
Today's topics:
Errors during PersistentPerl Compilation <bol@adv.magwien.gv.at>
Re: Exiting threads via signal sln@netherlands.com
Re: Exiting threads via signal <timothy.hill@gmail.com>
Re: Exiting threads via signal <timothy.hill@gmail.com>
Re: Exiting threads via signal <sreservoir@gmail.com>
Re: Exiting threads via signal <sysadmin@example.com>
Re: remove one element with splice sln@netherlands.com
Re: remove one element with splice <yankeeinexile@gmail.com>
Re: software engineering, program construction <wrmattil@ix.netcom.com>
Re: software engineering, program construction <uri@StemSystems.com>
Re: software engineering, program construction <wrmattil@ix.netcom.com>
Re: software engineering, program construction <ben@morrow.me.uk>
Re: software engineering, program construction <wrmattil@ix.netcom.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Nov 2009 11:56:55 +0100
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Errors during PersistentPerl Compilation
Message-Id: <1258023435.735505@proxy.dienste.wien.at>
Hi,
I'm trying to install PersistentPerl 2.22 on a Fedora 10 system with Perl
5.10.0 installed. During the make, I get some errors from gcc:
perperl_perl.c: In function 'find_scr':
perperl_perl.c:258: error: expected expression before 'PersistentScript'
perperl_perl.c: In function 'get_string':
perperl_perl.c:449: error: expected expression before 'char'
perperl_perl.c: In function 'cwd_new':
perperl_perl.c:484: error: expected expression before 'PersistentCwd'
perperl_perl.c: In function 'onerun':
perperl_perl.c:808: warning: comparison between pointer and integer
perperl_perl.c:809: warning: comparison between pointer and integer
perperl_perl.c:810: warning: comparison between pointer and integer
perperl_perl.c: In function 'perperl_perl_init':
perperl_perl.c:918: warning: passing argument 2 of 'perl_parse' from
incompatible pointer type
Deos someone use PersistentPerl under an environment like this? Or - since
the module seems to be very old (October 2003) - is there a newer module
which provides persistent context (didn't found somewhat on CPAN)?
Greetings, Ferry
--
Ing. Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: ferdinand.bolhar-nordenkampf@wien.gv.at
------------------------------
Date: Wed, 11 Nov 2009 19:28:52 -0800
From: sln@netherlands.com
Subject: Re: Exiting threads via signal
Message-Id: <l20nf5pebovp7f9gua6236parpptm01ton@4ax.com>
On Wed, 11 Nov 2009 12:50:14 -0800, sln@netherlands.com wrote:
>On Wed, 11 Nov 2009 04:08:50 -0800 (PST), Prince Al <timothy.hill@gmail.com> wrote:
>
>>Hi,
>>
>>I am trying to write some code that creates threads to run data load
>>jobs. There is also an extra thread created that watches for a
>>specific file to be created. When this file is found, the watcher
>>thread sends stop signals to all currently running threads. My code
>>appears to exit correctly, but I cannot seem to get the subroutine of
>>the SIG command to exit correctly.
>>
>>We are running HP-UX and the version of Perl we have is 5.8.8 (with
>>thread support obviously). A cut down version of my code is below.
>>
>>Thanks in advance for any help :)
>>
>>Cheers
>>
>>Tim
>>
>
>It looks like detach() is being called before $SIG{'STOP'} sub,
>so try detaching in the handler itself.
>
>Of course after 20 seconds, the thread exits on its own, therefore
>the handler is invalid in that case.
>
>Also, detach will need to be called on the thread if it is no longer
>running. Put in a check for that in the watcher thread. This way, the
>body of flock_test() can exit after an arbitrary amount of time.
>
>
>Try this ...
>
I'm actually shocked folks post code that *doesen't* work
without trying different things and debug.
Just like, 'here it is, fix it', .. blah, blah, blah. typical.
-sln
------------------------------
Date: Thu, 12 Nov 2009 00:42:21 -0800 (PST)
From: Prince Al <timothy.hill@gmail.com>
Subject: Re: Exiting threads via signal
Message-Id: <0602de62-6997-4e9a-b3b8-f17546bb99ad@c3g2000yqd.googlegroups.com>
On 12 Nov, 03:28, s...@netherlands.com wrote:
> I'm actually shocked folks post code that *doesen't* work
> without trying different things and debug.
>
> Just like, 'here it is, fix it', .. blah, blah, blah. typical.
> -sln
Well if I had managed to get it to work, then why would I have
bothered to post?! I have been at this for two days now, trying to get
it to work, but to no avail... Thanks for taking the time to reply,
but next time, please don't bother if that's your attitude.
------------------------------
Date: Thu, 12 Nov 2009 01:07:45 -0800 (PST)
From: Prince Al <timothy.hill@gmail.com>
Subject: Re: Exiting threads via signal
Message-Id: <5a29288b-2b46-4a04-8551-1ee724281c88@z41g2000yqz.googlegroups.com>
Ok, thanks for the replies - managed to fix my problem. The solution
was to change 'STOP' to 'HUP' - not sure why tho!
Cheers
Tim
------------------------------
Date: Thu, 12 Nov 2009 16:48:10 -0500
From: sreservoir <sreservoir@gmail.com>
Subject: Re: Exiting threads via signal
Message-Id: <hdhvq6$a16$1@aioe.org>
Prince Al wrote:
> Ok, thanks for the replies - managed to fix my problem. The solution
> was to change 'STOP' to 'HUP' - not sure why tho!
>
> Cheers
>
> Tim
sigstop is not blockable. the program stops, or lack of permissions.
at least,on unix-like systems.
--
"Six by nine. Forty two."
"That's it. That's all there is."
"I always thought something was fundamentally wrong with the universe"
------------------------------
Date: Thu, 12 Nov 2009 15:05:48 -0800
From: Wanna-Be Sys Admin <sysadmin@example.com>
Subject: Re: Exiting threads via signal
Message-Id: <gx0Lm.8261$ky1.6637@newsfe14.iad>
sln@netherlands.com wrote:
>
> I'm actually shocked folks post code that *doesen't* work
> without trying different things and debug.
>
> Just like, 'here it is, fix it', .. blah, blah, blah. typical.
> -sln
Are you replying to yourself about your own code you told the OP to use?
Or are you accusing the OP of not trying to get it to work before they
posted? If so, how would you know what they've tried or not? Why did
you bother replying if you're going to get upset about taking the time
to reply?
--
Not really a wanna-be, but I don't know everything.
------------------------------
Date: Wed, 11 Nov 2009 16:59:46 -0800
From: sln@netherlands.com
Subject: Re: remove one element with splice
Message-Id: <manmf5t9pfe1h29cfpvtcal0r98be2etb9@4ax.com>
On Wed, 11 Nov 2009 11:58:58 -0500, monkeys paw <user@example.net> wrote:
>I am trying to remove array elements where age is > 42.
>I think splice is the function to use but i'm having
>a problem getting it to work right. Here is the code,
>what i would like array to equal at the end is just
>two elements, bobbi and steve.
>
FWIW if not breaking on first occurance (ie: with grep), and
you do not have a complex schema ..
use strict;
use warnings;
use Data::Dumper;
use Benchmark ':hireswallclock';
my @array = (
{ name => 'steve', age => 42 },
{ name => 'bobbi', age => 33 },
{ name => 'kate', age => 55 },
{ name => 'bob', age => 58 },
);
my @array_bak = @array;
my ($tdif, $t0, $t1);
print "\nBenching grep() ...\n";
$t0 = new Benchmark;
for (1 .. 500_000)
{
@array = @array_bak;
@array = grep { $_->{age} <= 42 } @array;
}
$t1 = new Benchmark;
$tdif = timediff($t1, $t0);
print "the code took: ",timestr($tdif),"\n";
print Dumper(\@array);
print "\nBenching for(;;) splice() ...\n";
$t0 = new Benchmark;
for (1 .. 500_000)
{
@array = @array_bak;
for (my $i=$#array; $i>=0; $i--) {
$array[$i]{age} > 42 and splice @array, $i, 1;
}
}
$t1 = new Benchmark;
$tdif = timediff($t1, $t0);
print "the code took: ",timestr($tdif),"\n";
print Dumper(\@array);
__END__
-sln
------------------------------
Date: Wed, 11 Nov 2009 13:55:26 -0600
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: remove one element with splice
Message-Id: <m1ljicu98x.fsf@mac.lan>
Lawrence Statton <yankeeinexile@gmail.com> writes:
Oops .. my bad ... I forgot you wanted the NEGATIVE ... Add a "!" in the obvious place :)
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Data::Dumper qw/Dumper/;
>
> sub some_other_function {
> my $datum = shift;
> return $datum->{age} <= 42; # or whatever more complex test you need
> }
>
>
> my @array = (
> { name => 'steve', age => 42 },
> { name => 'bobbi', age => 33 },
> { name => 'kate', age => 55 },
> { name => 'bob', age => 58 },
> );
>
> @array = grep some_other_function($_), @array;
@array = grep !some_other_function($_), @array;
>
> print Dumper \@array;
------------------------------
Date: Wed, 11 Nov 2009 17:32:48 -0600
From: "William R. Mattil" <wrmattil@ix.netcom.com>
Subject: Re: software engineering, program construction
Message-Id: <hdfhin$u5k$1@news.eternal-september.org>
Ben Morrow wrote:
>
> for my $key (sort keys %$hash) {
> my $person = $hash{$key};
> print $OUT qq("$person->{name}","$person->{id}"\n);
> }
>
Ben,
This fails to compile on my Unix system perl v5.8.0
Global symbol "$hash" requires explicit package name at ./perl.pl line 62.
Global symbol "%hash" requires explicit package name at ./perl.pl line 63.
Did I get it wrong ?
Regards
Bill
--
William R. Mattil
http://www.celestial-images.com
------------------------------
Date: Wed, 11 Nov 2009 18:44:10 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: software engineering, program construction
Message-Id: <87ljicwrsl.fsf@quad.sysarch.com>
>>>>> "WRM" == William R Mattil <wrmattil@ix.netcom.com> writes:
WRM> Ben Morrow wrote:
>>
>> for my $key (sort keys %$hash) {
>> my $person = $hash{$key};
>> print $OUT qq("$person->{name}","$person->{id}"\n);
>> }
>>
WRM> This fails to compile on my Unix system perl v5.8.0
WRM> Global symbol "$hash" requires explicit package name at ./perl.pl line 62.
WRM> Global symbol "%hash" requires explicit package name at ./perl.pl line 63.
ben made some minor errors in his untested code. it looks like he meant
to use $data which is passed a hash ref from the main line code. so that
code should be (untested again):
for my $key (sort keys %$data) {
my $person = $data->{$key};
print $OUT qq("$person->{name}","$person->{id}"\n);
note that i also changed the second line to $data-> since it is a ref
and not a hash.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 11 Nov 2009 17:47:08 -0600
From: "William R. Mattil" <wrmattil@ix.netcom.com>
Subject: Re: software engineering, program construction
Message-Id: <hdfidi$vfv$1@news.eternal-september.org>
Uri Guttman wrote:
>>>>>> "WRM" == William R Mattil <wrmattil@ix.netcom.com> writes:
>
> WRM> Ben Morrow wrote:
> >>
> >> for my $key (sort keys %$hash) {
> >> my $person = $hash{$key};
> >> print $OUT qq("$person->{name}","$person->{id}"\n);
> >> }
> >>
>
> WRM> This fails to compile on my Unix system perl v5.8.0
>
> WRM> Global symbol "$hash" requires explicit package name at ./perl.pl line 62.
> WRM> Global symbol "%hash" requires explicit package name at ./perl.pl line 63.
>
> ben made some minor errors in his untested code. it looks like he meant
> to use $data which is passed a hash ref from the main line code. so that
> code should be (untested again):
>
> for my $key (sort keys %$data) {
> my $person = $data->{$key};
> print $OUT qq("$person->{name}","$person->{id}"\n);
>
> note that i also changed the second line to $data-> since it is a ref
> and not a hash.
>
> uri
>
Uri,
Thank You
Regards
Bill
--
William R. Mattil
http://www.celestial-images.com
------------------------------
Date: Wed, 11 Nov 2009 23:58:10 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: software engineering, program construction
Message-Id: <ilvrs6-bt41.ln1@osiris.mauzo.dyndns.org>
Quoth "Uri Guttman" <uri@StemSystems.com>:
>
> ben made some minor errors in his untested code. it looks like he meant
> to use $data which is passed a hash ref from the main line code. so that
> code should be (untested again):
>
> for my $key (sort keys %$data) {
> my $person = $data->{$key};
> print $OUT qq("$person->{name}","$person->{id}"\n);
>
> note that i also changed the second line to $data-> since it is a ref
> and not a hash.
Yes. Thanks for the correction.
Ben
------------------------------
Date: Wed, 11 Nov 2009 19:59:23 -0600
From: "William R. Mattil" <wrmattil@ix.netcom.com>
Subject: Re: software engineering, program construction
Message-Id: <hdfq5i$2i5$1@news.eternal-september.org>
Ben Morrow wrote:
> Quoth "Uri Guttman" <uri@StemSystems.com>:
>> ben made some minor errors in his untested code. it looks like he meant
>> to use $data which is passed a hash ref from the main line code. so that
>> code should be (untested again):
>>
>> for my $key (sort keys %$data) {
>> my $person = $data->{$key};
>> print $OUT qq("$person->{name}","$person->{id}"\n);
>>
>> note that i also changed the second line to $data-> since it is a ref
>> and not a hash.
>
> Yes. Thanks for the correction.
>
> Ben
>
Ben,
Thanks for posting the code in the first place ..... it was very
straight forward for the most part and easy to understand.
Regards
Bill
--
William R. Mattil
http://www.celestial-images.com
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 2672
***************************************