Re: Wait for background processes to complete
- From: "Peter J. Holzer" <hjp-usenet2@xxxxxx>
- Date: Fri, 18 Jan 2008 16:20:57 +0100
On 2008-01-18 02:02, grocery_stocker <cdalten@xxxxxxxxx> wrote:
On Jan 16, 9:37 pm, Ben Morrow <b...@xxxxxxxxxxxx> wrote:
The only thing that matters about %kids are its keys: we never use
the values, so they can be set to anything. I prefer using 1 since
then the values are all true; you can get slightly better memory use
with
$kids{$pid} = ();
which inserts the key but doesn't create a value for it at all, but
then you have to test with exists, which I find annoying. Since in
this case I don't test for existance of keys at all, this doesn't
matter: using 1 is just a habit.
Okay, why would you have to test for exists if
$kids{$pid} = ();
just creates something like undef.
Consider:
#!/usr/bin/perl
use warnings;
use strict;
my %kids;
$kids{3} = ();
$kids{5} = ();
for (1 .. 9) {
print "$_\n" if is_kid($_);
}
sub is_kid {
return exists($kids{$_[0]});
}
__END__
3
5
Please find an implementation for sub is_kid which doesn't use exists.
hp
.
- Follow-Ups:
- Re: Wait for background processes to complete
- From: pgodfrin
- Re: Wait for background processes to complete
- References:
- Wait for background processes to complete
- From: pgodfrin
- Re: Wait for background processes to complete
- From: pgodfrin
- Re: Wait for background processes to complete
- From: Ben Morrow
- Re: Wait for background processes to complete
- From: grocery_stocker
- Re: Wait for background processes to complete
- From: Ben Morrow
- Re: Wait for background processes to complete
- From: grocery_stocker
- Wait for background processes to complete
- Prev by Date: Re: Wait for background processes to complete
- Next by Date: Re: non nntp usenet
- Previous by thread: Re: Wait for background processes to complete
- Next by thread: Re: Wait for background processes to complete
- Index(es):
Relevant Pages
|