[24478] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6660 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 7 14:05:57 2004

Date: Mon, 7 Jun 2004 11:05:09 -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           Mon, 7 Jun 2004     Volume: 10 Number: 6660

Today's topics:
        CGI.pm popup_menu questions (Emil Tarazi)
    Re: CGI.pm popup_menu questions <nobull@mail.com>
    Re: Convert unicode string to "basic characters" (Anno Siegel)
    Re: Convert unicode string to "basic characters" <ppagee@yahoo.com>
    Re: Cute bit of Perl to Assign $1,$2 to named variables <vek@station02.ohout.pharmapartners.nl>
    Re: Cute bit of Perl to Assign $1,$2 to named variables <gnari@simnet.is>
    Re: Cute bit of Perl to Assign $1,$2 to named variables (Bill)
    Re: Delete a line out of a flat file database <usenet@morrow.me.uk>
        Do you ever use awk? <socyl@987jk.com>
    Re: Do you ever use awk? <jeffrey.schwab@comcast.net>
    Re: Do you ever use awk? <richard@zync.co.uk>
    Re: Do you ever use awk? <usenet@morrow.me.uk>
    Re: Do you ever use awk? ctcgag@hotmail.com
    Re: Do you ever use awk? <scott.stearns@visi.com>
    Re: Do you ever use awk? <uri@stemsystems.com>
    Re: Do you ever use awk? <michal@gortel.phys.ualberta.ca>
    Re: Do you ever use awk? <usenet@morrow.me.uk>
    Re: grab output shell <tadmc@augustmail.com>
    Re: grab output shell <marcus314@yahoo.com>
    Re: grab output shell <usenet@morrow.me.uk>
        killing my children (Oliver)
    Re: killing my children ctcgag@hotmail.com
    Re: killing my children <usenet@morrow.me.uk>
    Re: Memory problem with XML::DOM::Parser??? <tadmc@augustmail.com>
    Re: Memory problem with XML::DOM::Parser??? <markus.mohr@mazimoi.de>
        Need constant screen with periodic updates <cjdugan@lucent.com>
    Re: Need constant screen with periodic updates <usenet@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Jun 2004 07:48:35 -0700
From: et@emilt.com (Emil Tarazi)
Subject: CGI.pm popup_menu questions
Message-Id: <be262dcb.0406070648.3a6cd275@posting.google.com>

I am using the popup_menu feature in CGI.pm for a simple webform. When
i click an option I would like that option to be the "selected" choice
on the menu once I submit the form. However, I realised that the value
field in the HTML must be all lowercase (regardless of the case of the
query string) so that there is a proper match. Is this a bug or a
feature?

-et


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

Date: 07 Jun 2004 16:03:32 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: CGI.pm popup_menu questions
Message-Id: <u9llizl8aj.fsf@wcl-l.bham.ac.uk>

et@emilt.com (Emil Tarazi) writes:

> I am using the popup_menu feature in CGI.pm for a simple webform. When
> i click an option I would like that option to be the "selected" choice
> on the menu once I submit the form. However, I realised that the value
> field in the HTML must be all lowercase (regardless of the case of the
> query string) so that there is a proper match. Is this a bug or a
> feature?

No quite sure what you are saying bu it sounds like a bug, or maybe a
misconception.  Could you please post a minimal but complete script
that you have actully run and found to display the symptoms you tried
to describe.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 7 Jun 2004 13:31:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Convert unicode string to "basic characters"
Message-Id: <ca1qoa$52a$1@mamenchi.zrz.TU-Berlin.DE>

Mike Mimic  <ppagee@yahoo.com> wrote in comp.lang.perl.misc:
> Hi!
> 
> Calle Dybedahl wrote:
> > That just doesn't work. In Swedish (for example), ö is not an accented
> > o, it's a letter entirely of its own. Changing the first for the
> > second will have drastic semantic consequences, like for example
> > changing the word for "to hear" ("höra") into the word for "whore" ("hora").
> > 
> > If you really want to destroy information in your strings, I think
> > that the most honest way is to replace everything you can't (or don't
> > want to) handle by question marks or something else that makes it
> > really obvious that you've deleted stuff.
> 
> OK, you have convinced me. I will replace them with '?'.
> 
> But I am still curious. Is it possible? And how?

"It" is ill-defined.  Some characters look like the superposition of
separate glyphs, but that doesn't mean they are actually composed
(and de-composable).  If they are, there is no problem.  They would
appear as two separate characters in Unicode, one of which has the
property of being combining.  You can suppress the combining mark
and use the unmodified character.

However, most "composed" characters don't appear a such in Unicode.
In that case, nothing inherent in Unicode will tell you what they
can be thought to be composed of.  You will have to define that
yourself, according to the conventions of the language used.

Anno


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

Date: Mon, 07 Jun 2004 15:49:54 +0200
From: Mike Mimic <ppagee@yahoo.com>
Subject: Re: Convert unicode string to "basic characters"
Message-Id: <ca1rqp$h8r$1@planja.arnes.si>

Hi!

Anno Siegel wrote:
> However, most "composed" characters don't appear a such in Unicode.
> In that case, nothing inherent in Unicode will tell you what they
> can be thought to be composed of.  You will have to define that
> yourself, according to the conventions of the language used.

Thanks. I think that I understand now.


Mike


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

Date: 07 Jun 2004 13:53:09 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <slrncc8sq5.jg4.vek@station02.ohout.pharmapartners.nl>

On Sat, 5 Jun 2004 17:31:19 +0000 (UTC),
    J Krugman <jkrugman345@yahbitoo.com> wrote:


>
> What I'm saying is just that the number of unnecessarily aggressive
> posts seem to me well above average for this type of newsgroup, at
> least in my experience.
>

Try comp.lang.c for a while.  Then you might find people here are
quite nice in comparison.


Villy


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

Date: Mon, 7 Jun 2004 15:01:55 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <ca1vtu$6fj$1@news.simnet.is>

"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:vng8c0llnq1gotrdaork171h13asqnvqr3@4ax.com...
> On Sat, 5 Jun 2004 17:31:19 +0000 (UTC), J Krugman
> <jkrugman345@yahbitoo.com> wrote:
>
> I must say that I was surprised myself to see the OP's publicizing his
> supposedly amazing discovery that AFAICT is one that everybody having
> to do with perl is likely to make say, in the very first few days of
> coding...

well, I just imagined that was exacly what was happening; the OP
is taking his first serious look at perl.

gnari





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

Date: 7 Jun 2004 09:21:49 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <239ce42f.0406070821.6b05ddf9@posting.google.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<o7h8c0ln1anf6kh711r75juu7orn7302s8@4ax.com>...

> (i) the possibility of putting perl code (hooks) directly into @INC;

Yep, this one was just an aha! how come I never saw that before!
experience for me also in the past few months. Inserting refernces
into @INC allows some non-admin user level manipulations of home
directory CGI modules in taint mode I had thought too hard before.


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

Date: Mon, 7 Jun 2004 15:27:39 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Delete a line out of a flat file database
Message-Id: <ca21ha$o4o$1@wisteria.csv.warwick.ac.uk>


Quoth Eric Bohlman <ebohlman@omsdev.com>:
> Ben Morrow <usenet@morrow.me.uk> wrote in 
> news:c9q3p1$9cb$1@wisteria.csv.warwick.ac.uk:
> 
> > Alternatively, you could open the file '+<' and then lock it LOCK_EX,
> > and truncate it rather than closing/reopening.
> 
> Which solves the problem.  In a "read and update" situation you can't 
> afford to release the lock in between.

Gah! Sorry, yes, you're right of course. Clearly not thinkig straight...

Ben

-- 
I've seen things you people wouldn't believe: attack ships on fire off
the shoulder of Orion; I watched C-beams glitter in the dark near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.                                                   ben@morrow.me.uk


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

Date: Mon, 7 Jun 2004 13:25:54 +0000 (UTC)
From: kj <socyl@987jk.com>
Subject: Do you ever use awk?
Message-Id: <ca1qd2$s7s$1@reader2.panix.com>




Do people proficient in Perl have any use for awk/gawk anymore?
Are there things that you still prefer to do using awk/gawk over
perl?

Thank you for your opinions!

kj

-- 
NOTE: In my address everything before the period is backwards.


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

Date: Mon, 07 Jun 2004 09:33:14 -0400
From: Jeff Schwab <jeffrey.schwab@comcast.net>
Subject: Re: Do you ever use awk?
Message-Id: <XrednQ9yTIwf81ndRVn-uA@comcast.com>

kj wrote:
> Do people proficient in Perl have any use for awk/gawk anymore?
> Are there things that you still prefer to do using awk/gawk over
> perl?

I use awk occasionally for pulling particular columns out of a sequence 
of records, e.g. awk '{ print $3 }' to get the third entry on each line 
of a file.


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

Date: Mon, 07 Jun 2004 15:06:18 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Do you ever use awk?
Message-Id: <ca1sou$1bo$1@news.freedom2surf.net>

In article <ca1qd2$s7s$1@reader2.panix.com>, "kj" <socyl@987jk.com> wrote:


> Do people proficient in Perl have any use for awk/gawk anymore? Are
> there things that you still prefer to do using awk/gawk over perl?
> Thank you for your opinions!
> kj
> 

I only started using unix (Linux) about 5 or 6 years ago so the main
thing I get out of using awk is a sense of history ;-)

Seriously, I tend to use awk when I'm doing lots of things through a bunch
of shell pipes. eg

ls *.txt | awk 'fname = $0; gsub(/_old/,"_new"); print fname " " $0;' |
xargs -n2 mv

I s'pose it could be done with perl too <shrug>.

Rich


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

Date: Mon, 7 Jun 2004 15:43:02 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Do you ever use awk?
Message-Id: <ca22e6$o4o$3@wisteria.csv.warwick.ac.uk>


Quoth kj <socyl@987jk.com>:
> 
> Do people proficient in Perl have any use for awk/gawk anymore?
> Are there things that you still prefer to do using awk/gawk over
> perl?

My system (gentoo linux) has awk in /bin and perl in /usr/bin, so it
uses awk for a lot of stuff in the system startup scripts that I'd
probably have used Perl for if possible (and Gentoo'd probably've used
Python, but that's their loss... :).

Ben

-- 
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t    # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.


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

Date: 07 Jun 2004 16:53:36 GMT
From: ctcgag@hotmail.com
Subject: Re: Do you ever use awk?
Message-Id: <20040607125336.626$Z1@newsreader.com>

kj <socyl@987jk.com> wrote:
> Do people proficient in Perl have any use for awk/gawk anymore?
> Are there things that you still prefer to do using awk/gawk over
> perl?

If anything, I now use awk even more, and more proficiently. (Some places
the Perl docs will compare some feature to awk, things that I never knew
awk could do in the first place.  But now that I know, I use it.).

But mostly I still use it for getting a few columns.  I find that with
Perl I often forget either the 'l' or the 'n' in -lnae, or I forget that
'a' splits into @F, not @_ or @a, or forget that the 'e' has to be last
switch in the switch list.  It is easier to get awk right on the first try,
for me.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 7 Jun 2004 12:35:47 -0500
From: "Scott Stearns" <scott.stearns@visi.com>
Subject: Re: Do you ever use awk?
Message-Id: <40c4a693$0$90568$a1866201@newsreader.visi.com>

You might end up working at a place where people don't really use Perl and a
lot of the stuff is written with shell scripting. In that case, you'd see a
lot of awk. It is neat to work with those Unix tools...it's rewarding when a
script that looks like Greek actually does what you wanted it to. :)

-Scott


"kj" <socyl@987jk.com> wrote in message
news:ca1qd2$s7s$1@reader2.panix.com...
>
>
>
> Do people proficient in Perl have any use for awk/gawk anymore?
> Are there things that you still prefer to do using awk/gawk over
> perl?
>
> Thank you for your opinions!
>
> kj
>
> -- 
> NOTE: In my address everything before the period is backwards.




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

Date: Mon, 07 Jun 2004 17:36:47 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Do you ever use awk?
Message-Id: <x7pt8bmfrk.fsf@mail.sysarch.com>

>>>>> "SS" == Scott Stearns <scott.stearns@visi.com> writes:

  SS> You might end up working at a place where people don't really use
  SS> Perl and a lot of the stuff is written with shell scripting. In
  SS> that case, you'd see a lot of awk. It is neat to work with those
  SS> Unix tools...it's rewarding when a script that looks like Greek
  SS> actually does what you wanted it to. :)

in my pre-perl days, i did tons of shell/awk stuff. i am so glad i don't
have to go back to awk. :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 7 Jun 2004 17:49:05 +0000 (UTC)
From: Michal Jaegermann <michal@gortel.phys.ualberta.ca>
Subject: Re: Do you ever use awk?
Message-Id: <ca29qh$9n8$1@tabloid.srv.ualberta.ca>

Jeff Schwab <jeffrey.schwab@comcast.net> wrote:
>> Do people proficient in Perl have any use for awk/gawk anymore?
>> Are there things that you still prefer to do using awk/gawk over
>> perl?
> 
> I use awk occasionally for pulling particular columns out of a sequence 
> of records, e.g. awk '{ print $3 }' to get the third entry on each line 
> of a file.

For that "complicated" usage you do not need awk at all (or perl for
that matter)

while read a b c d ; do echo $c ; done < my_file

A "fancier" /bin/sh solution employs a function which does 'echo $3' or
'shift $1 ; echo $1' if a column you want has a number higher than 9 and
you are passing a desired column number as the first argument.

  Michal


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

Date: Mon, 7 Jun 2004 18:03:22 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Do you ever use awk?
Message-Id: <ca2ala$218$2@wisteria.csv.warwick.ac.uk>


Quoth Michal Jaegermann <michal@gortel.phys.ualberta.ca>:
> Jeff Schwab <jeffrey.schwab@comcast.net> wrote:
> >> Do people proficient in Perl have any use for awk/gawk anymore?
> >> Are there things that you still prefer to do using awk/gawk over
> >> perl?
> > 
> > I use awk occasionally for pulling particular columns out of a sequence 
> > of records, e.g. awk '{ print $3 }' to get the third entry on each line 
> > of a file.
> 
> For that "complicated" usage you do not need awk at all (or perl for
> that matter)
> 
> while read a b c d ; do echo $c ; done < my_file

That will obey shell quoting rules when splitting, though, which may well not
be desirable.

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Mon, 7 Jun 2004 08:05:11 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: grab output shell
Message-Id: <slrncc8q07.cfv.tadmc@magna.augustmail.com>

Andrea Spitaleri <spiritelllo@interfree.it> wrote:

> how do I grab the output from shell after system?


You should read the documentation for the functions that you use.

If you had adopted such a common sense method, you wouldn't be here,
as the docs for system tell how to capture the output.


   perldoc -f system


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 07 Jun 2004 18:06:07 +0200
From: Marcus Stollsteimer <marcus314@yahoo.com>
Subject: Re: grab output shell
Message-Id: <2iji3gFnepeaU1@uni-berlin.de>

Tad McClellan wrote:

> Andrea Spitaleri <spiritelllo@interfree.it> wrote:
> 
>> how do I grab the output from shell after system?
>  
> You should read the documentation for the functions that you use.
> 
> If you had adopted such a common sense method, you wouldn't be here,
> as the docs for system tell how to capture the output.

Andrea Spitaleri <spiritelllo@interfree.it> wrote also:

> I would like to grab these lines before I get the prompt "program>"
> and check for the versione.


I think the problem of the OP is, that the output should be grabbed
and processed while the program is still running.


Andrea,

I don't know how to do this, but this might be
a possible workaround:

has your 'program' a version option (like --version or -v)
that prints only the version and exits?
Then you could call it first to grab the output (qx// or "backticks")
and in case it's the right version call it again.

Regards,
Marcus

-- 
I don't believe in an afterlive,
although I am bringing a change of underwear. -- W. Allen



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

Date: Mon, 7 Jun 2004 17:45:30 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: grab output shell
Message-Id: <ca29jq$13f$2@wisteria.csv.warwick.ac.uk>


Quoth Marcus Stollsteimer <marcus314@yahoo.com>:
> Tad McClellan wrote:
> 
> > Andrea Spitaleri <spiritelllo@interfree.it> wrote:
> > 
> >> how do I grab the output from shell after system?
> >  
> > You should read the documentation for the functions that you use.
> > 
> > If you had adopted such a common sense method, you wouldn't be here,
> > as the docs for system tell how to capture the output.
> 
> Andrea Spitaleri <spiritelllo@interfree.it> wrote also:
> 
> > I would like to grab these lines before I get the prompt "program>"
> > and check for the versione.
> 
> I think the problem of the OP is, that the output should be grabbed
> and processed while the program is still running.
> 
> Andrea,
> 
> I don't know how to do this, but this might be
> a possible workaround:

Check out Expect.pm.

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk                                    The Levellers, 'Believers'


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

Date: 7 Jun 2004 08:58:13 -0700
From: spacehopper_man@yahoo.com (Oliver)
Subject: killing my children
Message-Id: <5818fca8.0406070758.6c284e6e@posting.google.com>

hi all - 
  I'm struggling to reap my children.

 I have a parent process that is forking to do work in parallel.

 I need to keep track and manage the number of child processes.

 I am doing this by creating a communication link between child and
parent using "socketpair" - the idea being that the parent can check
on the state of the children by checking the state of the handle to
the child (* comments/crits. on this approach welcome).

 all this avoids signals - yipee!! - will nearly :( - I find I have to
have a  signal handler anyway to read my children.

 I don't really want to do this - so I have tried: $SIG{CHILD} =
'IGNORE';

 ... but whatever I do I seem to frequently (but not always) get
children hanging around after the parent dies.

 I've tried every variant on the usual reaper code imaginable - this
sort of thing:

sub REAPER {
    my $child;
    print "reaping - \n";
    while ((my $waitedpid = waitpid(-1,WNOHANG)) > 0) {
        print "reaped $waitedpid" . ($? ? " with exit $?" : '') .
"\n";
    }

    $SIG{CHLD} = \&REAPER;  # loathe sysV
}

I've also tried to make sure that the handles created by socketpair
are closed/undefined - but no joy.

any ideas out there?

cheers,
Oli


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

Date: 07 Jun 2004 17:05:17 GMT
From: ctcgag@hotmail.com
Subject: Re: killing my children
Message-Id: <20040607130517.662$eC@newsreader.com>

spacehopper_man@yahoo.com (Oliver) wrote:
> hi all -
>   I'm struggling to reap my children.
>
>  I have a parent process that is forking to do work in parallel.
>
>  I need to keep track and manage the number of child processes.
>
>  I am doing this by creating a communication link between child and
> parent using "socketpair" - the idea being that the parent can check
> on the state of the children by checking the state of the handle to
> the child (* comments/crits. on this approach welcome).
>
>  all this avoids signals - yipee!! - will nearly :( - I find I have to
> have a  signal handler anyway to read my children.

I assume you meant to type "reap", not "read"?
>
>  I don't really want to do this - so I have tried: $SIG{CHILD} =
> 'IGNORE';
>
>  ... but whatever I do I seem to frequently (but not always) get
> children hanging around after the parent dies.

You have this backwards.  If you don't reap your children, they will become
zombies, and hang around until the parents exists.  Reaping your children
when they happen to die is not related to killing your children when you
die.

>
> any ideas out there?

The two easiest that spring to mind are storing the PID of your children
and then using "kill" to kill them before you die; or better IMHO is to
have the children check on the pipe from the parent, and then exit
gracefully when the parent pipe closes.

But without knowing more about what you are doing, and more specifically,
why the existing parallel modules on CPAN aren't an option for you, it is
hard to give more specific advice.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 7 Jun 2004 17:41:09 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: killing my children
Message-Id: <ca29bl$13f$1@wisteria.csv.warwick.ac.uk>

Quoth spacehopper_man@yahoo.com (Oliver):
> 
>  I have a parent process that is forking to do work in parallel.
> 
>  I need to keep track and manage the number of child processes.
> 
>  I am doing this by creating a communication link between child and
> parent using "socketpair" - the idea being that the parent can check
> on the state of the children by checking the state of the handle to
> the child (* comments/crits. on this approach welcome).

If you need this to communicate with the child, fine. If you just have
it to see when the child dies, there's no need: you can just keep a list
of child pids and check them with

waitpid $pid, WNOHANG

>  all this avoids signals - yipee!! - will nearly :( - I find I have to
> have a  signal handler anyway to read my children.

Avoiding signals is not necessarily a good thing: they are there to tell
you about asynchronous events, such as a child exiting. If you use the
signal, then there's no need to check whether a child has exited or not:
if and when it does, you'll be told. OTOH, if you need or want to check
anyway, there's no need for the signal so you can ignore it.

>  I don't really want to do this - so I have tried: $SIG{CHILD} =
> 'IGNORE';

If you have a system this works on (most modern Unices), and the parent
doesn't need to know when the children die, this is the best solution.
Note that the signal is called CHLD or CLD, not CHILD.

>  ... but whatever I do I seem to frequently (but not always) get
> children hanging around after the parent dies.

Ah... you have misunderstood something crucial :). SIGCHLD is only sent
when a child *dies*: i.e., when it calls exit or is sent a fatal signal.
If your children have died and become zombies (because you didn't reap
them) and the parent exits, they will be inherited by init which will
clean them up for you. If your children are outliving their parent, then
they never exited: you need to make sure they do when they've finished
their work.

If you want to kill all your children when the parent dies, you will
need to do this explicitly: something like

my @kids;
my $parent = $$;

END {
    if ($parent = $$) {
        kill TERM => $_ for @kids;
    }
}

where you populate @kids with all your child pids. You can then set up a
SIGTERM handler in the child if you want to catch this event and do some
cleanup (and then exit).

>  I've tried every variant on the usual reaper code imaginable - this
> sort of thing:
> 
> sub REAPER {
>     my $child;
>     print "reaping - \n";
>     while ((my $waitedpid = waitpid(-1,WNOHANG)) > 0) {
>         print "reaped $waitedpid" . ($? ? " with exit $?" : '') .
> "\n";
>     }
> 
>     $SIG{CHLD} = \&REAPER;  # loathe sysV

There's no need to loath SysV unless you're using it: on any modern
system you almost certainly have reliable signals. You can check with

perl -V:d_sigaction

: if this shows 'define' then perl is using reliable signals. If it
doesn't, then you need to read your signal(2) to find out if you have
BSDish or SysVish signal handling. (Of course, if you want
ultra-portability to ancient systems then you can't assume you have
reliable signals; but that's always the price of portablility.)

> }

You should also consider using one of the modules on CPAN for this task.

Ben

-- 
And if you wanna make sense / Whatcha looking at me for?          (Fiona Apple)
                            * ben@morrow.me.uk *


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

Date: Mon, 7 Jun 2004 08:10:05 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Memory problem with XML::DOM::Parser???
Message-Id: <slrncc8q9d.cfv.tadmc@magna.augustmail.com>

Markus Mohr <markus.mohr@mazimoi.de> wrote:


[ snip 100 lines of upside-down full-quoted text ]


> Okay, Ben, thank you very much. Here is the complete code for
> "CXML.pm" for your interest.


[ snip over 1000 lines of code!! ]


Please learn how to properly compose a followup.

Have you seen the Posting Guidelines that are posted here frequently?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 07 Jun 2004 15:53:19 +0200
From: Markus Mohr <markus.mohr@mazimoi.de>
Subject: Re: Memory problem with XML::DOM::Parser???
Message-Id: <qps8c056jvtequp304nb1pt86ns6vmqo5v@4ax.com>

On Mon, 7 Jun 2004 08:10:05 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:

>Markus Mohr <markus.mohr@mazimoi.de> wrote:
>
>
>[ snip 100 lines of upside-down full-quoted text ]
>
>
>> Okay, Ben, thank you very much. Here is the complete code for
>> "CXML.pm" for your interest.
>
>
>[ snip over 1000 lines of code!! ]
>
>
>Please learn how to properly compose a followup.

Willingly.

>Have you seen the Posting Guidelines that are posted here frequently?

No.

Sincerely


Markus Mohr



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

Date: Mon, 07 Jun 2004 11:11:46 -0500
From: Kris Dugan <cjdugan@lucent.com>
Subject: Need constant screen with periodic updates
Message-Id: <40C493C2.7040108@lucent.com>

I am using a Unix/Solaris 8/9 environment.

I want to make a tool that will constantly read a structure of
information and display that information (or "paint it") to the
screen.  Rather than having the information scroll by, I want
a way in which the screen would be "repainted".  Sample Screen:

-------------------------------------------------
|	foo: 6		bar: 12			|
|	this: 18	that: 20		|
|etc.						|
-------------------------------------------------

If the values change, I want the screen to be repainted, as opposed
to using "printf" to print it to a screen or logfile.

I am aware that C has the "cursor" libraries, which will do what
I am looking for.  Upon first examination, this looked somewhat
complicated.  Are there any other modules/libraries that would
accomplish this kind of task (in any other languages) that would
be simple to use?

I am not doing anything with X windows, so this would just be text
to the screen.



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

Date: Mon, 7 Jun 2004 17:46:41 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Need constant screen with periodic updates
Message-Id: <ca29m1$13f$3@wisteria.csv.warwick.ac.uk>


Quoth Kris Dugan <cjdugan@lucent.com>:
> I am using a Unix/Solaris 8/9 environment.
> 
> I want to make a tool that will constantly read a structure of
> information and display that information (or "paint it") to the
> screen.  Rather than having the information scroll by, I want
> a way in which the screen would be "repainted".  Sample Screen:
> 
> -------------------------------------------------
> |	foo: 6		bar: 12			|
> |	this: 18	that: 20		|
> |etc.						|
> -------------------------------------------------
> 
> If the values change, I want the screen to be repainted, as opposed
> to using "printf" to print it to a screen or logfile.
> 
> I am aware that C has the "cursor" libraries, which will do what
> I am looking for.  Upon first examination, this looked somewhat
> complicated.  Are there any other modules/libraries that would
> accomplish this kind of task (in any other languages) that would
> be simple to use?

In Perl you can use Term::ANSIScreen to achieve this (very easily).

Ben

-- 
   Although few may originate a policy, we are all able to judge it.
                                             - Pericles of Athens, c.430 B.C.
  ben@morrow.me.uk


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

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 V10 Issue 6660
***************************************


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