if (my $child = fork()) { # in parent while (! -f "output.txt") { print "Waiting for output.txt\n"; sleep 10; }; print "Found output.txt, continuing\n"; } else { # In child, just run p2 exec 'p2'; # exit }; # do more stuff print "Waiting for child to finish\n"; wait $child;