my $count = 0; foreach (@temp_files) { $count++; print "$program run #$count with temp file \"$_\"...\n"; my $pid = $pm->start and next; system("$program < $_ &"); #Run program located in $PATH sleep 3; if (($count%2) == 0) { print "even run number\n"; #somehow wait for the 2 children processes #$pm -> wait_all_children()? } $pm->finish; # Terminates the child process }