in reply to Limiting the number of forks
There is a module that already provides this functionality: Parallel::ForkManager
The code above is an excerpt from the man page of P::FM.use Parallel::ForkManager; $pm = new Parallel::ForkManager($MAX_PROCESSES); foreach $data (@all_data) { # Forks and returns the pid for the child: my $pid = $pm->start and next; ... do some work with $data in the child process ... $pm->finish; # Terminates the child process }
Hope this helps,
larryk perl -le "s,,reverse killer,e,y,rifle,lycra,,print"
|
---|
In Section
Seekers of Perl Wisdom