Perl: redirecting STDERR to STDOUT 2008-07-14 07:17pm
I had occasion that I needed to redirect all STDERR output (die statements) to STDOUT. A webapp I wrote only looks at STDOUT, so this code causes STDERR to merge with STDOUT.
Alternately you can also do it by reassigning the raw file handles:
You can get fancy and redirect all output to a log file:
Code:
open(STDERR, ">&STDOUT"); |
Alternately you can also do it by reassigning the raw file handles:
Code:
*STDERR = *STDOUT; |
You can get fancy and redirect all output to a log file:
Code:
open(LOG,">/tmp/foo.log"); *STDERR = *LOG; *STDOUT = *LOG; |