use Parallel::ForkManager qw( ) use constant MAX_PROCESSES => 3; my $pm = Parallel::ForkManager->new(MAX_PROCESSES); foreach $data (@array) { # 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 }