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.
In reply to Forking 100 processes, 5 at a time by nagan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |