use strict;
use warnings;
use Parallel::ForkManager;
my @sleepy_times=(3,5,2,8,1,6,4,7,9,10);
my $pm = new Parallel::ForkManager(10);
foreach my $sleepy_time (@sleepy_times) {
$pm->start and next; # do the fork
print "sleeping for $sleepy_time seconds\n";
sleep $sleepy_time;
print "done ($sleepy_time)\n";
$pm->finish; # do the exit in the child process
}
$pm->wait_all_children;