in reply to create new task from main program
There are many ways you could do this, here is one using the Parallel::ForkManager module:
use Parallel::ForkManager; use strict; use warnings; my $max = 50 # maximum number of children to create my $pm = new Parallel::ForkManager($max); while(1) { # consider using "while(condition())" here instead # ... if (condition()) { my $pid = $pm->start and next; other(); $pm->finish(); } } sub other { # don't use capitalised subroutine names # ... whatever you want to do in the child }
Hope this helps
|
|---|