foreach my $node_name (@nodes) { my $port_hashref = Mod1->sub1($node_name); my $pid = fork; die "Unable to fork: $!\n" unless defined $pid; unless ($pid) { # Child process. Mod2->sub2($node_name, $port_hashref); exit; # When done, child should terminate. } } 1 while -1 != wait; # Reap children.