use strict; use warnings; use Parallel::ForkManager (); use constant $MAX_PROCESSES => 3; { my $pm = Parallel::ForkManager->new($MAX_PROCESSES); foreach my $fw (qw(fw1 fw2 fw3 fw4 fw5)) { my $pid = $pm->start and next; exec "remotelogfile $fw logfile > /var/$fw.log" or die("Unable to launch \"remotelogfile $fw\": $!\n"); # Will never reach this, but that's ok since it only calls exit. $pm->finish; # Terminates the child process } }