print "before spawn\n"; spawn(); print "after spawn\n"; sub spawn { my $pid = open(my $xx, "sleep 3 2>&1|") or die "fork: $!"; print "implicitly waiting for child...\n"; # the proper way to wait for the command to exit: # close($xx); } # output: before spawn implicitly waiting for child... # sleep... after spawn