[29358] in Perl-Users-Digest
Perl-Users Digest, Issue: 602 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 29 11:14:22 2007
Date: Fri, 29 Jun 2007 08:14:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 29 Jun 2007 Volume: 11 Number: 602
Today's topics:
Simple fork examples <shmh@bigpond.net.au>
Re: Simple fork examples <simon.chao@fmr.com>
Re: Simple fork examples <shmh@bigpond.net.au>
Re: Simple fork examples QoS@domain.invalid
Re: Simple fork examples <noreply@gunnar.cc>
Re: The Modernization of Emacs: terminology buffer and (Joel J. Adamson)
uninitialized value in a sort block <alexxx.magni@gmail.com>
Re: uninitialized value in a sort block <mritty@gmail.com>
Re: uninitialized value in a sort block anno4000@radom.zrz.tu-berlin.de
Re: uninitialized value in a sort block <wahab-mail@gmx.net>
Re: uninitialized value in a sort block <alexxx.magni@gmail.com>
Re: uninitialized value in a sort block <paduille.4061.mumia.w+nospam@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 29 Jun 2007 14:13:12 GMT
From: "Simon" <shmh@bigpond.net.au>
Subject: Simple fork examples
Message-Id: <Yr8hi.999$4A1.348@news-server.bigpond.net.au>
Hi guys!
I have read through the perldoc and must be really stupid.
I want to get my hands on some really basic example scripts of using fork,
and what it is used for.
Ive looked on the net and cant find too many examples of this anywhere, that
I can get a grip on.
Any information and/or scripts so I can start playing with this stuff and
learn it, instead of reading obscure doco would be great just to get a start
on it.
Thanku.
------------------------------
Date: Fri, 29 Jun 2007 07:20:06 -0700
From: it_says_BALLS_on_your forehead <simon.chao@fmr.com>
Subject: Re: Simple fork examples
Message-Id: <1183126806.423422.290430@u2g2000hsc.googlegroups.com>
On Jun 29, 10:13 am, "Simon" <s...@bigpond.net.au> wrote:
> Hi guys!
>
> I have read through the perldoc and must be really stupid.
>
> I want to get my hands on some really basic example scripts of using fork,
> and what it is used for.
> Ive looked on the net and cant find too many examples of this anywhere, that
> I can get a grip on.
>
use strict; use warnings;
$| = 1;
my $num_kids = shift;
my $pid;
for my $i ( 1.. $num_kids ) {
$pid = fork;
die "couldn't fork" if (!defined $pid);
if ( $pid == 0 ) {
print "$i about to sleep 3 secs...\n";
sleep 3;
print "$i done sleeping!\n";
exit;
}
print "pid '$pid'...i am parent\n";
}
do {
$pid = waitpid( -1, 0 );
} until $pid == -1;
------------------------------
Date: Fri, 29 Jun 2007 14:28:07 GMT
From: "Simon" <shmh@bigpond.net.au>
Subject: Re: Simple fork examples
Message-Id: <XF8hi.1000$4A1.769@news-server.bigpond.net.au>
Hi balls!
Mate thank u for that...I do feel dumb..probably am..just a newbie.
I ran your script, and got the following..
C:\>ballsonforehead.pl
Use of uninitialized value in foreach loop entry at C:\ballsonforehead.pl
line 9
.
Use of uninitialized value in foreach loop entry at C:\ballsonforehead.pl
line 9
.
"it_says_BALLS_on_your forehead" <simon.chao@fmr.com> wrote in message
news:1183126806.423422.290430@u2g2000hsc.googlegroups.com...
> On Jun 29, 10:13 am, "Simon" <s...@bigpond.net.au> wrote:
>> Hi guys!
>>
>> I have read through the perldoc and must be really stupid.
>>
>> I want to get my hands on some really basic example scripts of using
>> fork,
>> and what it is used for.
>> Ive looked on the net and cant find too many examples of this anywhere,
>> that
>> I can get a grip on.
>>
>
>
> use strict; use warnings;
>
> $| = 1;
>
> my $num_kids = shift;
>
> my $pid;
> for my $i ( 1.. $num_kids ) {
> $pid = fork;
> die "couldn't fork" if (!defined $pid);
> if ( $pid == 0 ) {
> print "$i about to sleep 3 secs...\n";
> sleep 3;
> print "$i done sleeping!\n";
> exit;
> }
> print "pid '$pid'...i am parent\n";
> }
> do {
> $pid = waitpid( -1, 0 );
> } until $pid == -1;
>
>
>
------------------------------
Date: Fri, 29 Jun 2007 14:43:17 GMT
From: QoS@domain.invalid
Subject: Re: Simple fork examples
Message-Id: <9U8hi.9$q12.1@trnddc08>
"Simon" <shmh@bigpond.net.au> wrote in message-id: <XF8hi.1000$4A1.769@news-server.bigpond.net.au>
>
[snip]
> I ran your script, and got the following..
>
> C:\>ballsonforehead.pl
> Use of uninitialized value in foreach loop entry at C:\ballsonforehead.pl
> line 9
> .
> Use of uninitialized value in foreach loop entry at C:\ballsonforehead.pl
> line 9
> .
>
> "it_says_BALLS_on_your forehead" <simon.chao@fmr.com> wrote in message
> news:1183126806.423422.290430@u2g2000hsc.googlegroups.com...
> > On Jun 29, 10:13 am, "Simon" <s...@bigpond.net.au> wrote:
> >> Hi guys!
> >>
> >> I have read through the perldoc and must be really stupid.
> >>
> >> I want to get my hands on some really basic example scripts of using
> >> fork,
> >> and what it is used for.
> >> Ive looked on the net and cant find too many examples of this anywhere,
> >> that
> >> I can get a grip on.
> >>
> >
> >
> > use strict; use warnings;
> >
> > $| = 1;
> >
> > my $num_kids = shift;
^
notice the shift does not supply a default.
you must start this script with a integer as an argument.
> > my $pid;
> > for my $i ( 1.. $num_kids ) {
> > $pid = fork;
> > die "couldn't fork" if (!defined $pid);
> > if ( $pid == 0 ) {
> > print "$i about to sleep 3 secs...\n";
> > sleep 3;
> > print "$i done sleeping!\n";
> > exit;
> > }
> > print "pid '$pid'...i am parent\n";
> > }
> > do {
> > $pid = waitpid( -1, 0 );
> > } until $pid == -1;
> >
In addition, if you want the script to work on more platforms,
afaik it is better to use threads.
------------------------------
Date: Fri, 29 Jun 2007 16:48:06 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Simple fork examples
Message-Id: <5ekkiqF37fngrU1@mid.individual.net>
Simon wrote:
> I want to get my hands on some really basic example scripts of using fork,
> and what it is used for.
Check out the CPAN module Parallel::ForkManager. It's a useful tool, and
by reading its docs, including the examples, you may get a better
understanding of the concept as well.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 29 Jun 2007 09:35:30 -0400
From: jadamson@partners.org (Joel J. Adamson)
Subject: Re: The Modernization of Emacs: terminology buffer and keybinding
Message-Id: <87myyi6fz1.fsf@W0053328.mgh.harvard.edu>
blmblm@myrealbox.com <blmblm@myrealbox.com> writes:
> I find Windows and its tools as frustrating as you seem to find
> Unix, but I strongly suspect that being shown the ropes by someone
> who understands and likes the system would help a lot. <shrug>
I feel the same way about Windows being frustrating, however I find
that having a Windows "expert" around helps very little. Heck, *I*
was a Windows expert for as long as I was using it. I always found it
to be totally opaque. It always seemed like the only way to make
things work was to BUY something --- something that really offended
me. It became clear to me quickly that Windows is basically a
billboard on a CRT --- the help files only told me to buy stuff, or
how "fun and easy" it was to do something, without actually saying how
to do it. When I got XP and wanted to change my desktop theme ---
guess what? They decided to start charging for that too.
With Windows I never got it; with Unix of any kind (linux, SunOS,
etc), I have felt like I got it right away.
Joel
--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA 02114
(617) 643-1432
(303) 880-3109
*Joel's guide to sending attachments:
1. put all the files you want to send in a folder and archive the
folder using tar, then compress it with gzip or bzip2
2. please send me .pdf, .html, or text in place of Word documents:
http://www.gnu.org/philosophy/sylvester-response.html
*Did you know there's a FREE alternative to using word processors?
http://www.edafe.org/latex/
http://en.wikipedia.org/wiki/LaTeX
http://nitens.org/taraborelli/latex
------------------------------
Date: Fri, 29 Jun 2007 03:38:57 -0700
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: uninitialized value in a sort block
Message-Id: <1183113537.636667.297640@n2g2000hse.googlegroups.com>
Hi Perlers,
I have a strange behavior happening sometimes to my filesystem
crawler:
inside tha wanted subroutine, I check the mod.times of the files:
@a=glob "$File::Find::name/*";
@a=sort {-M $a <=> -M $b} @a;
sometimes(rarely) what I get is:
Use of uninitialized value in numeric comparison (<=>) at /usr/src/
chktimes line 33.
unfortunately I don't know why it's happening (file times seem ok to
me),
neither how to track the error, since the warning is printed on the
console, not synched with the print()'s I wrote here and there.
any hint?
thanks!
Alessandro Magni
------------------------------
Date: Fri, 29 Jun 2007 11:05:58 -0000
From: Paul Lalli <mritty@gmail.com>
Subject: Re: uninitialized value in a sort block
Message-Id: <1183115158.771931.278780@q69g2000hsb.googlegroups.com>
On Jun 29, 6:38 am, "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com>
wrote:
> Hi Perlers,
>
> I have a strange behavior happening sometimes to my filesystem
> crawler:
> inside tha wanted subroutine, I check the mod.times of the files:
>
> @a=glob "$File::Find::name/*";
> @a=sort {-M $a <=> -M $b} @a;
>
> sometimes(rarely) what I get is:
> Use of uninitialized value in numeric comparison (<=>) at
> /usr/src/ chktimes line 33.
>
> unfortunately I don't know why it's happening (file times seem
> ok to me),
> neither how to track the error, since the warning is printed on the
> console, not synched with the print()'s I wrote here and there.
I don't know why -M would be returning undef offhand (maybe you lack
permissions to one of the files?) But it shouldn't be that hard to
debug...
my @a=glob "$File::Find::name/*";
my @mtimes = map { [$_, -M $_] } @a;
for (@mtimes) {
print "File: '$_->[0]'. Mtime: $_->[1]\n";
}
See which files are giving you the problem, and then see if there's
anything "special" about that file on the disk.
Paul Lalli
------------------------------
Date: 29 Jun 2007 11:24:53 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: uninitialized value in a sort block
Message-Id: <5ek8g5F389trdU1@mid.dfncis.de>
Paul Lalli <mritty@gmail.com> wrote in comp.lang.perl.misc:
> On Jun 29, 6:38 am, "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com>
> wrote:
> > Hi Perlers,
> >
> > I have a strange behavior happening sometimes to my filesystem
> > crawler:
> > inside tha wanted subroutine, I check the mod.times of the files:
> >
> > @a=glob "$File::Find::name/*";
> > @a=sort {-M $a <=> -M $b} @a;
> >
> > sometimes(rarely) what I get is:
> > Use of uninitialized value in numeric comparison (<=>) at
> > /usr/src/ chktimes line 33.
> >
> > unfortunately I don't know why it's happening (file times seem
> > ok to me),
> > neither how to track the error, since the warning is printed on the
> > console, not synched with the print()'s I wrote here and there.
>
> I don't know why -M would be returning undef offhand (maybe you lack
> permissions to one of the files?) ...
... The file could have disappeared by the time -M is checked.
Anno
------------------------------
Date: Fri, 29 Jun 2007 13:28:00 +0200
From: Mirco Wahab <wahab-mail@gmx.net>
Subject: Re: uninitialized value in a sort block
Message-Id: <f62qn4$e3p$1@mlucom4.urz.uni-halle.de>
alexxx.magni@gmail.com wrote:
> I check the mod.times of the files:
>
> @a=glob "$File::Find::name/*";
> @a=sort {-M $a <=> -M $b} @a;
>
> sometimes(rarely) what I get is:
> Use of uninitialized value in numeric comparison (<=>) at /usr/src/
> chktimes line 33.
> any hint?
What would you expect to get from unix `stat` call (which is
what -M is based on), if you can't "stat" the file.
[http://perldoc.perl.org/functions/-X.html]
....
Unless otherwise documented, it returns 1
for true and '' for false, or the undefined
value if the file doesn't exist.
...
Regards
M.
------------------------------
Date: Fri, 29 Jun 2007 04:41:40 -0700
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: Re: uninitialized value in a sort block
Message-Id: <1183117300.852291.257760@n60g2000hse.googlegroups.com>
thank you,
I feel really stupid, since it was <again> a special-character
problem. Usually I never encounter similar problems, since I seldom
use spaces or special chars in filenames.
But a crawler just goes, well, everywhere! So it ended up on a dir
whose name contained spec-chars.
Now it works well, with:
@a=glob quotemeta($File::Find::name) . "/*";
thanks a lot!
Alessandro
On 29 Giu, 13:05, Paul Lalli <mri...@gmail.com> wrote:
> On Jun 29, 6:38 am, "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com>
> wrote:
>
>
>
> > Hi Perlers,
>
> > I have a strange behavior happening sometimes to my filesystem
> > crawler:
> > inside tha wanted subroutine, I check the mod.times of the files:
>
> > @a=glob "$File::Find::name/*";
> > @a=sort {-M $a <=> -M $b} @a;
>
> > sometimes(rarely) what I get is:
> > Use of uninitialized value in numeric comparison (<=>) at
> > /usr/src/ chktimes line 33.
>
> > unfortunately I don't know why it's happening (file times seem
> > ok to me),
> > neither how to track the error, since the warning is printed on the
> > console, not synched with the print()'s I wrote here and there.
>
> I don't know why -M would be returning undef offhand (maybe you lack
> permissions to one of the files?) But it shouldn't be that hard to
> debug...
>
> my @a=glob "$File::Find::name/*";
> my @mtimes = map { [$_, -M $_] } @a;
> for (@mtimes) {
> print "File: '$_->[0]'. Mtime: $_->[1]\n";
>
> }
>
> See which files are giving you the problem, and then see if there's
> anything "special" about that file on the disk.
>
> Paul Lalli
------------------------------
Date: Fri, 29 Jun 2007 11:54:36 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: uninitialized value in a sort block
Message-Id: <0q6hi.1987$rR.169@newsread2.news.pas.earthlink.net>
On 06/29/2007 05:38 AM, alexxx.magni@gmail.com wrote:
> Hi Perlers,
>
> I have a strange behavior happening sometimes to my filesystem
> crawler:
> inside tha wanted subroutine, I check the mod.times of the files:
>
> @a=glob "$File::Find::name/*";
> @a=sort {-M $a <=> -M $b} @a;
>
> sometimes(rarely) what I get is:
> Use of uninitialized value in numeric comparison (<=>) at /usr/src/
> chktimes line 33.
>
> unfortunately I don't know why it's happening (file times seem ok to
> me),
> neither how to track the error, since the warning is printed on the
> console, not synched with the print()'s I wrote here and there.
>
> any hint?
>
Write debugging code that tests for undef:
for (@a) {
print "Modification time undefined for $_\n" unless (-M $_);
}
That should reveal the file that causes the warning.
> thanks!
>
> Alessandro Magni
>
You're welcome.
------------------------------
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:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#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 602
**************************************