fork Handling the return value is a bit complicated. A recent article by Aristotle contains a nice and concise icon, which in your case looks like this:
#!/usr/bin/env perl use 5.010000; use strict; use warnings qw(all); say 'before the child process'; given (fork) { when (undef) { die "couldn't fork: $!" } when (0) { exec $^X => 'testing.pl'; } default { my $pid = $_; say 'before wait command'; waitpid $pid, 0; say 'after 20 secs of waiting'; } }
Pay attention to the line exec $^X => '...' : the variable $ ^ X contains the full path to the current Perl executable, so a “correct version of Perl” will be guaranteed. In addition, a system call is meaningless when you first open it.
source share