for ($count=0;$count<5;$count++){ unless (defined ($pid[$count] = fork)) { print "im dying\n"; die "cannot fork: $!"; } unless ($pid[$count]) { print "im a kid with pid $$\n"; `do my thing`; exit; #child stops ehre } } # Parent continues here