in reply to Re^4: How to print STDOUT to a file
in thread How to print STDOUT to a file

the bullet proof way:
my $pid = fork; if (defined $pid and $pid == 0) { open STDOUT, ">", $fn or die; exec $script, @args; exit 1; } if ($pid) { waitpid($pid); $? and die "error on child: $?" } else { die "unable to fork: $!"; }