my $pm = new Parallel::ForkManager(5); for (1...10) { my $pid = $pm->start and next; my $exp = Expect_common->new(); # expect send ... # $pm->finish; # Terminates the child process } $pm->wait_all_children;