for (...) { my $pid = $pm->start; if ($pid) { # We're in the parent. ...[ do something with $pid ]... next; } # We're in the child. ... }