foreach (1..10) { my $pid; print "$$ starting loop $_"; if( $pid = fork()) { print "$$ created child $pid"; } else { print "\t", "child $$ created ok"; sleep(int(rand(10))); print "\t", "child $$ done, outta here"; exit; } print "$$ exiting loop $_" if $pid; } # 1 while wait != -1; # *cough* print "$$ all done!";