[29971] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1214 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 19 16:09:47 2008

Date: Sat, 19 Jan 2008 13:09:07 -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           Sat, 19 Jan 2008     Volume: 11 Number: 1214

Today's topics:
    Re: Can't Install Perl as Non-Root <ben@morrow.me.uk>
    Re: how to put subroutines in separate files and call? <ben@morrow.me.uk>
    Re: Making variable field names <ldolan@thinkinghatbigpond.net.au>
        new CPAN modules on Sat Jan 19 2008 (Randal Schwartz)
        PERL MAP HELP <mailursubbu@gmail.com>
    Re: PERL MAP HELP <nobull67@gmail.com>
    Re: the God that never was <jurgenex@hotmail.com>
    Re: the God that never was <1usa@llenroc.ude.invalid>
    Re: the God that never was <john@castleamber.com>
    Re: Wait for background processes to complete <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 19 Jan 2008 07:12:54 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Can't Install Perl as Non-Root
Message-Id: <mgk865-3g1.ln1@osiris.mauzo.dyndns.org>


Quoth dawmail333 <Dawmail333@gmail.com>:
> Hi!
> 
> I was trying to install a personal version of Perl to my own user
> folder.  I am running on a remote webserver that uses Apache.  I have
> succeeded with the following steps:
> 
> wget http://perl.com/CPAN/src/stable.tar.gz
> tar zvxf stable.tar.gz
> cd perl-5.8.8
> sh Configure -de -Dprefix=/home/.bazooka/dawliam/perl/
> 
> This is the line I encounter problems on:
> make && make test && make install
> 
> This is the 'dump':
> Extracting find2perl (with variable substitutions)
> 
> make[1]: Leaving directory `/home/.bazooka/dawliam/perl-5.8.8/x2p'
> 
>         Making B (dynamic)
> opendir(./../../../../..): Permission denied at ../../lib/File/Find.pm
> line 604

File::Find is trying to work out its cwd, which means it needs to be
able to readdir all the directories down from /. Do you not have read
permission on /home?

> Use of chdir('') or chdir(undef) as chdir() is deprecated at ../../lib/
> File/Find
> .pm line 751.

This is a bug in File::Find. If it can't determine the cwd (and it
really needs to) it should fail, not start randomly chdiring all over
the place.

The rest of the errors are a consequence of being in the wrong
directory.

Is it possible for you to build perl (not necessarily install perl) in a
directory where you *can* read all the directories down from /? Perhaps
/tmp, if there's enough room there? Otherwise, try 5.10.0, which has a
newer version of Cwd that (at least on my machine) doesn't fail in the
same way.

Ben



------------------------------

Date: Sat, 19 Jan 2008 06:47:31 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: how to put subroutines in separate files and call?
Message-Id: <31j865-d71.ln1@osiris.mauzo.dyndns.org>


Quoth smallpond <smallpond@juno.com>:
> On Jan 18, 12:44 pm, birdso...@gmail.com wrote:
> 
> modules are not as hard as you probably think they are.
> Put one sub in a file foo.pm and add 'use foo;' in your

Don't use lowercase module names. They are reserved for pragmata. You
also want to think a little about a sensible name: try and fit it into
the CPAN hierarchy, as then the chance of name conflicts is smaller.

Ben



------------------------------

Date: Sat, 19 Jan 2008 15:39:32 GMT
From: "Peter Jamieson" <ldolan@thinkinghatbigpond.net.au>
Subject: Re: Making variable field names
Message-Id: <UQokj.5119$421.3514@news-server.bigpond.net.au>


"David Filmer" <usenet@davidfilmer.com> wrote in message 
news:DP-dnZAC9_cBzw3a4p2dnAA@giganews.com...
> Peter Jamieson wrote:
>> Is it possible to have my code change the INSERT INTO statement so that 
>> the fields change depending on the fields in each table?
>
> The SQL command is just a string scalar.  You can interpolate variables in 
> it just like any other string, such as:
>
> my $sth = $dbh->prepare("INSERT INTO 
> Treatment_table(mdate,venue,patient,dob,$c1,$c2,$c3)...
>
> If you want to determine what the column names are for a particular table, 
> use the column_info method of DBI.
>
> Of course, if you change either the table or the column names, you must 
> build a separate prepare statement.  You cannot prepare a generic database 
> plan and then execute it against different tables and columns.
>

Thanks David!
Your solution worked well!...your help is appreciated!....cheers, Peter 




------------------------------

Date: Sat, 19 Jan 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Jan 19 2008
Message-Id: <JuvMIH.13KF@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

App-TemplateServer-0.03
http://search.cpan.org/~jrockway/App-TemplateServer-0.03/
application to serve processed templates 
----
App-TemplateServer-0.04
http://search.cpan.org/~jrockway/App-TemplateServer-0.04/
application to serve processed templates 
----
Audio-Moosic-0.10
http://search.cpan.org/~flora/Audio-Moosic-0.10/
Moosic client library for Perl 
----
Audio-SndFile-0.07
http://search.cpan.org/~jdiepen/Audio-SndFile-0.07/
Portable reading and writing of sound files 
----
Bundle-POE-Simple-TCPIP-Services-1.04
http://search.cpan.org/~bingos/Bundle-POE-Simple-TCPIP-Services-1.04/
A bundle to install all POE simple TCP/IP services modules. 
----
Cache-Memcached-Fast-0.07
http://search.cpan.org/~kroki/Cache-Memcached-Fast-0.07/
Perl client for memcached, in C language 
----
Catalyst-Component-ACCEPT_CONTEXT-0.05
http://search.cpan.org/~jrockway/Catalyst-Component-ACCEPT_CONTEXT-0.05/
Make the current Catalyst request context available in Models and Views. 
----
DBD-Pg-2.0.0_3
http://search.cpan.org/~dbdpg/DBD-Pg-2.0.0_3/
PostgreSQL database driver for the DBI module 
----
DBD-Pg-2.0.0_4
http://search.cpan.org/~dbdpg/DBD-Pg-2.0.0_4/
PostgreSQL database driver for the DBI module 
----
DateTime-Incomplete-0.03
http://search.cpan.org/~fglock/DateTime-Incomplete-0.03/
An incomplete datetime, like January 5 
----
Deliantra-Client-0.9964
http://search.cpan.org/~mlehmann/Deliantra-Client-0.9964/
----
Encode-JP-Mobile-0.22
http://search.cpan.org/~miyagawa/Encode-JP-Mobile-0.22/
????????? Shift_JIS (CP932) / UTF-8 ???????? 
----
Encode-JP-Mobile-0.23
http://search.cpan.org/~miyagawa/Encode-JP-Mobile-0.23/
????????? Shift_JIS (CP932) / UTF-8 ???????? 
----
HTML-ReplacePictogramMobileJp-0.01
http://search.cpan.org/~tokuhirom/HTML-ReplacePictogramMobileJp-0.01/
HTML ????????????? 
----
List-Parseable-1.00
http://search.cpan.org/~sbeck/List-Parseable-1.00/
routines to work with lists containing a simple language 
----
List-Rotation-Cycle-1.007
http://search.cpan.org/~pelagic/List-Rotation-Cycle-1.007/
Cycle through a list of values via a singleton object implemented as closure. 
----
Mac-iPhoto-Shell-0.16
http://search.cpan.org/~bdfoy/Mac-iPhoto-Shell-0.16/
----
Mac-iTerm-LaunchPad-1.008
http://search.cpan.org/~bdfoy/Mac-iTerm-LaunchPad-1.008/
----
Mango-0.01000_10
http://search.cpan.org/~claco/Mango-0.01000_10/
An ecommerce solution using Catalyst, Handel and DBIx::Class 
----
Memcached-libmemcached-0.1307
http://search.cpan.org/~timb/Memcached-libmemcached-0.1307/
Thin fast full interface to the libmemcached client API 
----
Moxy-0.06
http://search.cpan.org/~tokuhirom/Moxy-0.06/
Mobile web development proxy 
----
Net-MRIM-1.04
http://search.cpan.org/~aau/Net-MRIM-1.04/
Perl implementation of mail.ru agent protocol 
----
Net-UploadMirror-0.07
http://search.cpan.org/~knorr/Net-UploadMirror-0.07/
Perl extension for mirroring a local directory via FTP to the remote location 
----
OAuth-Lite-1.06
http://search.cpan.org/~lyokato/OAuth-Lite-1.06/
OAuth framework 
----
POE-Component-Server-Daytime-1.08
http://search.cpan.org/~bingos/POE-Component-Server-Daytime-1.08/
A POE component that implements an RFC 867 Daytime server. 
----
POE-Component-Server-Discard-1.08
http://search.cpan.org/~bingos/POE-Component-Server-Discard-1.08/
A POE component that implements an RFC 863 Discard server. 
----
POE-Component-Server-Ident-1.12
http://search.cpan.org/~bingos/POE-Component-Server-Ident-1.12/
A POE component that provides non-blocking ident services to your sessions. 
----
POE-Component-Server-Qotd-1.08
http://search.cpan.org/~bingos/POE-Component-Server-Qotd-1.08/
A POE component that implements an RFC 865 QotD server. 
----
POE-Component-Server-Time-1.08
http://search.cpan.org/~bingos/POE-Component-Server-Time-1.08/
A POE component that implements an RFC 868 Time server. 
----
POE-Filter-CSV-1.10
http://search.cpan.org/~bingos/POE-Filter-CSV-1.10/
A POE-based parser for CSV based files. 
----
POE-Filter-CSV_XS-1.08
http://search.cpan.org/~bingos/POE-Filter-CSV_XS-1.08/
A POE-based parser for CSV based files. 
----
Pod-Perldoc-ToToc-1.08
http://search.cpan.org/~bdfoy/Pod-Perldoc-ToToc-1.08/
Translate Pod to a Table of Contents 
----
Pod-ProjectDocs-0.35
http://search.cpan.org/~lyokato/Pod-ProjectDocs-0.35/
generates CPAN like pod pages 
----
Polyglot-0.14
http://search.cpan.org/~bdfoy/Polyglot-0.14/
a little language interpreter 
----
PowerDNS-Backend-MySQL-0.02
http://search.cpan.org/~augie/PowerDNS-Backend-MySQL-0.02/
Provides an interface to manipulate PowerDNS data in the MySQL Backend. 
----
PowerDNS-Control-Client-0.02
http://search.cpan.org/~augie/PowerDNS-Control-Client-0.02/
Provides an interface to control the PowerDNS daemon. 
----
PowerDNS-Control-Server-0.02
http://search.cpan.org/~augie/PowerDNS-Control-Server-0.02/
Provides an interface to control the PowerDNS daemon. 
----
Proc-Exists-0.01
http://search.cpan.org/~brianski/Proc-Exists-0.01/
quickly check for process existence 
----
Proc-Exists-0.02
http://search.cpan.org/~brianski/Proc-Exists-0.02/
quickly check for process existence 
----
Proc-Exists-0.03
http://search.cpan.org/~brianski/Proc-Exists-0.03/
quickly check for process existence 
----
SMS-Send-NL-MyVodafone-0.03
http://search.cpan.org/~blom/SMS-Send-NL-MyVodafone-0.03/
An SMS::Send driver for the my.vodafone.nl website 
----
Sort-DataTypes-2.00
http://search.cpan.org/~sbeck/Sort-DataTypes-2.00/
Sort a list of data using methods relevant to the type of data 
----
URI-Find-UTF8-0.01
http://search.cpan.org/~miyagawa/URI-Find-UTF8-0.01/
Finds URI from arbitrary text containing UTF8 raw characters in its path 
----
URI-Find-UTF8-0.02
http://search.cpan.org/~miyagawa/URI-Find-UTF8-0.02/
Finds URI from arbitrary text containing UTF8 raw characters in its path 
----
WWW-Ohloh-API-0.0.5
http://search.cpan.org/~yanick/WWW-Ohloh-API-0.0.5/
Ohloh API implementation 
----
YAML-Syck-1.01
http://search.cpan.org/~audreyt/YAML-Syck-1.01/
Fast, lightweight YAML loader and dumper 
----
autobox-Encode-0.02
http://search.cpan.org/~tokuhirom/autobox-Encode-0.02/
Encode with autobox 
----
perfSONAR_PS-Base-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Base-0.03/
----
perfSONAR_PS-Client-Echo-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Client-Echo-0.03/
A module that provides methods for interacting with perfSONAR Echo services. 
----
perfSONAR_PS-Client-LS-Remote-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Client-LS-Remote-0.03/
A module that provides a client API for an LS 
----
perfSONAR_PS-Client-Status-MA-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Client-Status-MA-0.03/
A module that provides methods for interacting with Status MA servers. 
----
perfSONAR_PS-Client-Status-SQL-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Client-Status-SQL-0.03/
A module that provides methods for interacting with a Status MA database directly. 
----
perfSONAR_PS-Client-Topology-MA-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Client-Topology-MA-0.03/
A module that provides methods for interacting with Topology MA servers. 
----
perfSONAR_PS-Client-Topology-XMLDB-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Client-Topology-XMLDB-0.03/
A module that provides methods for interacting with a Topology MA database directly. 
----
perfSONAR_PS-Collectors-Daemon-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Collectors-Daemon-0.03/
----
perfSONAR_PS-Collectors-LinkStatus-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Collectors-LinkStatus-0.03/
A module that will collect link status information and store the results into a Link Status MA. 
----
perfSONAR_PS-DB-File-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-DB-File-0.03/
A module that provides methods for adding 'database like' functions to files that contain XML markup. 
----
perfSONAR_PS-DB-RRD-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-DB-RRD-0.03/
A module that provides methods for dealing with rrd files through the RRDp perl module. 
----
perfSONAR_PS-DB-SQL-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-DB-SQL-0.03/
A module that provides methods for dealing with common SQL databases. 
----
perfSONAR_PS-DB-XMLDB-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-DB-XMLDB-0.03/
A module that provides methods for dealing with the Sleepycat [Oracle] XML database. 
----
perfSONAR_PS-Services-Daemon-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Services-Daemon-0.03/
----
perfSONAR_PS-Services-LS-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Services-LS-0.03/
----
perfSONAR_PS-Services-MA-Base-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Services-MA-Base-0.03/
----
perfSONAR_PS-Services-MA-SNMP-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Services-MA-SNMP-0.03/
----
perfSONAR_PS-Services-MA-Status-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Services-MA-Status-0.03/
A module that provides methods for the Status MA. 
----
perfSONAR_PS-Services-MA-Topology-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Services-MA-Topology-0.03/
A module that provides methods for the Topology MA. 
----
perfSONAR_PS-Status-Common-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Status-Common-0.03/
A module that provides common methods for Link Status clients and services within the perfSONAR-PS framework. 
----
perfSONAR_PS-Topology-Common-0.03
http://search.cpan.org/~perfsonar/perfSONAR_PS-Topology-Common-0.03/
A module that provides various utility functions for Topology structures. 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Sat, 19 Jan 2008 04:03:29 -0800 (PST)
From: Subra <mailursubbu@gmail.com>
Subject: PERL MAP HELP
Message-Id: <35cc9f1b-4147-47a2-a38a-55682c21fbf0@z17g2000hsg.googlegroups.com>

Hi,

 Can some one tell me how the below code works ???


605:            @cherou= map {
606:                    ($nf,@narg)=split(/:/,$_);
607:                    &{$::{"setup_$nf"}}($type,@narg); #returns the
subformat above
608:            }  exists $setupstuff{$ap} ? @{$setupstuff{$ap}} :
() ;



 And also pls let me know wts mean by &{$::{"setup_$nf"}}
($type,@narg).

 Is $:: used to access the defs from the other packages ???

Best Regards,
Sburam


------------------------------

Date: Sat, 19 Jan 2008 05:58:53 -0800 (PST)
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: PERL MAP HELP
Message-Id: <657cd273-fdf4-40b2-9f87-a616ea278676@i3g2000hsf.googlegroups.com>

On Jan 19, 12:03 pm, Subra <mailursu...@gmail.com> wrote:
> Hi,
>
>  Can some one tell me how the below code works ???

An explanation of the sematics of...

map { BLOCK } LIST

 ...can be found in the Perl reference manual.

If there's anything you find unclear in there please let us know what.

Any off-the-cuff explanation that someone could post to a newsgroup is
unlikely to be better than the one in the manual.

> 605:            @cherou= map {
> 606:                    ($nf,@narg)=split(/:/,$_);
> 607:                    &{$::{"setup_$nf"}}($type,@narg); #returns the
> subformat above
> 608:            }  exists $setupstuff{$ap} ? @{$setupstuff{$ap}} :
> () ;
>
>  And also pls let me know wts mean by &{$::{"setup_$nf"}}
> ($type,@narg).
>
>  Is $:: used to access the defs from the other packages ???

$::{ whatever } is actually a simply a hash lookup in the special hash
called %:: which is the root of the Perl symbol table. %:: is actually
the same hash as %main:: which is the symbol table of the default
package 'main'.  Using this syntax you can only access symbols  form
the default package main.

Therefore supping $nf='foo' the expression $::{"setup_$nf"} therefore
returns the symbol table entry (GLOB) from the package main for the
symbol setup_foo (aka *main::setup_foo ). Indeed $::{"setup_$nf"} is
almost the same as saying *{"main::setup_$nf"} except using the
explicit symbolic GLOBref will auto-vivify the GLOB and makes the
intent much clearer.

&{ whatever } will they coerce whatever into a CODEref. Since whatever
is *main::setup_foo the whatever gets coerced into
*main::setup_foo{CODE} aka \&main::setup_foo.

&{$::{"setup_$nf"}}($type,@narg)  is therefore equivalent to
main::setup_foo($type,@narg). OK that's a slight simplification in
that I'm assuming &main::setup_foo doesn't have a prototype - usually
a safe assumption.

All in all I'd just say

"main::setup_$nf"->($type,@narg);

Now, I hear you all (and indeed strict.pm) cry "you're using symrefs".
Yes I am. So I'd need actually to say:

no strict 'refs';
"main::setup_$nf"->($type,@narg);

But it is important to note is that using symrefs is not evil just
because some pseudo-deity declared that it should be the case. It's
evil because mucking about with the symbol table is fraught with
dangers. If you are going to do this anyhow then do it with the
simplest syntax Perl offers and put a nice big red flag "no strict" so
that it is obvious what you're doing. Don't go using a more obfuscated
approach to avoid the need for "no strict".

Also the construct
  exits( EXPR )? @{ EXPR } : ();

Seems unduly complex. If EXPR does not exist then it'll also be false
so it's simpler to say

  @{ EXPR || [] };

Oh, and the original code was missing at least one my().

            my @cherou= map {
                   my ($nf,@narg)=split /:/;
                   no strict 'refs';
                   "main::setup_$nf"->($type,@narg);
             } @{$setupstuff{$ap} || []};


------------------------------

Date: Sat, 19 Jan 2008 15:38:51 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: the God that never was
Message-Id: <la64p39sn7it8b1nkmn3124ar684jgb1qc@4ax.com>

small giant <mutawafayez@yahoo.com> wrote:
>Islam is the only religion which 

continuously spams Usenet.

jue


------------------------------

Date: Sat, 19 Jan 2008 19:17:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: the God that never was
Message-Id: <Xns9A2A916F61FBAasu1cornelledu@127.0.0.1>

Jürgen Exner <jurgenex@hotmail.com> wrote in 
news:la64p39sn7it8b1nkmn3124ar684jgb1qc@4ax.com:

> small giant <mutawafayez@yahoo.com> wrote:
>>Islam is the only religion which 
> 
> continuously spams Usenet.

What is the point of this response?

Please do not respond to spam. Just report this message to Google as spam 
and let the filters work.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



------------------------------

Date: 19 Jan 2008 20:04:14 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: the God that never was
Message-Id: <Xns9A2A8F21EEBB8castleamber@130.133.1.4>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:

> Jürgen Exner <jurgenex@hotmail.com> wrote in 
> news:la64p39sn7it8b1nkmn3124ar684jgb1qc@4ax.com:
> 
>> small giant <mutawafayez@yahoo.com> wrote:
>>>Islam is the only religion which 
>> 
>> continuously spams Usenet.
> 
> What is the point of this response?

Hate spreading? Ignorance? It's sad.

-- 
John


------------------------------

Date: Sat, 19 Jan 2008 12:12:09 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Wait for background processes to complete
Message-Id: <slrnfp3moc.oa5.hjp-usenet2@hrunkner.hjp.at>

On 2008-01-18 22:19, comp.llang.perl.moderated <ced@blv-sam-01.ca.boeing.com> wrote:
> On Jan 18, 1:33 pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>> Zombies are not a concern in this case. When you post a followup to a
>> question of an obvious perl beginner, please try to provide a solution
>> to his problem. A solution to a completely different problem will just
>> confuse him, especially, if you don't say that it is a solution for a
>> completely different problem.
>
> I believe the OP was given a couple of solutions.
> Sometimes discussions do segue off in different
> directions but the info can be useful at times.

True, but there should be some continuity from one posting to the next.
The code in the posting you replied to had a serious problem, but it
didn't produce zombies (Well, one - for a short time). Butting in with a
zombie-avoidance method was a complete non-sequitur. It would have been
ok if you had followed up to an article with code which did actually
produce zombies, or if you had started your article with some indication
that you are not proposing a solution to the problem at hand (something
like "This probably isn't the problem here, but in general ..." works
well).

> It was to me.  And I disagree -- for at least
> one of the solutions -- zombies could occur
> and need to be dealt with.

I don't recall seeing any solution which did produce zombies and was
otherwise correct (i.e. met the OP's specification). I can think of
at least two ways to achieve this (both of them wait for all children
but not necessarily in the order they terminate), but I don't agree that
in these cases "zombies need to be dealt with". In the worst case all
zombies will be collected immediately after the last child process
terminated. If the system can deal with $n active processes all 
be 


>> > To me the solutions are very close modulo the signal function setup.
>>
>> The signal function setup is the difference, yes. For the OP's problem a
>> signal handler is not only not needed, but does nothing at all to solve
>> the problem.
>>
>
> Again I disagree.  A viable alternative solution could make use of a
> SIGCHLD handler.

It could. It's just completely useless.

Assume that the loop which forks off the children registers them in
%kids.

Then the SIGCHLD handler could do something like this:

sub REAPER {
    for(;;) {
	$kid = waitpid(-1, WNOHANG);
	last if $kid <= 0;
	delete $kids{$kid};
    }
}

So, at the end of the program we just need to loop until %kids is empty:

while (keys %kids) {
}

But that's busy-waiting - it will consume 100 % CPU time. We could sleep
inside the loop, but how long? Until the next child terminates. Well, we
already have a function which does sleep until a child terminates - it's
called wait. So the loop turns into:

while (keys %kids) {
    my $kid = wait();
    delete $kids{$kid};
}

So now we have a loop at the end which waits for all children, and the
REAPER function has no useful function anymore. So we can delete it.

	hp



------------------------------

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 1214
***************************************


home help back first fref pref prev next nref lref last post