my $pm = Parallel::ForkManager->new(50); # 50 forks my $i = 0; while(i<50){ # start 50 forks $pm->start and next; processStream($stream); $i++; $pm->finish; # do the exit in the child process } $pm->wait_all_children(); # and then do nothing #### # max 4 processes simultaneously my $pm = Parallel::ForkManager->new(4); while( .. there are rows to fetch ..){ $pm->start and next; processStream($stream); $pm->finish; # do the exit in the child process } $pm->wait_all_children();