# UNTESTED # @srvrs is potentially LARGE array of servers to test # $frk is maximum number of processes to fork at one time. while ( @srvrs ) { SRVR: for (1..$frk) { $x = shift @srvrs or last SRVR; $pid = fork; if ( $pid ) { push @pids, $pid } elsif ( defined $pid ) { # DO thing with $x you want parallelized (testing servers) here exit; } else { die "fork failed\n"; } } waitpid($_, 0) for ( @pids ); }