foreach $element (@updevices){ @ip = split(':',$element); die "Could not fork()\n" unless defined ($pid = fork); if ($pid) { push @pids, $pid; next;} # ^ this is parent code, it pushes $pid to array # and goes back to the top of the loop # below is child code # it does something and then exits system("ping $ip[2] 1 > /dev/null"); $result = $?; print "ping $ip[0] $ip[2] $result\n"; if ( $result != 0) { print "$ip[0] is dead\n"; push(@dead, $ip[0]); } exit; # ^ child exits here # and basically stops (that's how exit works, after all) # and its exit code is 0; see perdoc -f exit } # after parent is done with the loop # it continues here # it has the array @pids # and all other global vars that your script # is full of...