Perl: redirect STDOUT and STDERR to a file
I need to redirect STDOUT and STDERR to a log file in my script. I didn't find really conclusive documentation on the best way to do this so here is what I came up with.
my $file = "/tmp/debug.log";
open(my $stdlog, ">", $file) or die("Cannot open $file");
*STDOUT = $stdlog;
*STDERR = $stdlog;