nagan has asked for the wisdom of the Perl Monks concerning the following question:
I'm new to this whole IPC thing, so please bear with me...
I need to run the same external executable 100 times with slightly different parameters, and I can only have 5 instances running at a time (not counting the initiating Perl script).
Here's my code:
$counter = 0; $pid_count = 0; do { if ($pid_count < 5) { ++$counter; ++$pid_count; if (!defined($$counter = fork())) { ## <---This is line 175 warn "Unable to fork $counter: $!"; } elsif ($$counter == 0) { print "Running this command line: $cmd[$counter]\n"; exec("$cmd[$counter]"); warn "Can't exec $cmd[$counter]: $!"; } else { waitpid($$counter, 0); --$pid_count; } } } until ($counter == $max_frag_id);
When I run this, I get the following error message: Modification of a read-only value attempted at script.pl line 175.
What does this mean and how do I fix it?
Many thanks!
Kevin J.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Forking 100 processes, 5 at a time
by Abigail-II (Bishop) on Jun 14, 2002 at 18:52 UTC | |
|
Re: Forking 100 processes, 5 at a time
by particle (Vicar) on Jun 14, 2002 at 18:50 UTC | |
by nagan (Initiate) on Jun 14, 2002 at 20:49 UTC | |
|
Re: Forking 100 processes, 5 at a time
by Anonymous Monk on Jun 14, 2002 at 23:15 UTC |