in reply to interleaf stdout stderr to a file
You can redirect stdout to stderr within your program using BEGIN{ open STDOUT, '>&STDERR' }; then both will come out interleaved via the unbuffered stderr; and you only need 2>file in order to put everything in a file:
E:\primes>perl -Mstrict -wE"BEGIN{ open STDOUT, '>&STDERR';} say 'hi'; + warn 1; say 'this is fun'; warn 2; say 'bye'" 2>log C:\test>type log hi 1 at -e line 1. this is fun 2 at -e line 1. bye
Note: I think that if you do this at the top of your main script, before you use any modules, their output will also be redirected, but I didn't create a module with warnings to try it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: interleaf stdout stderr to a file
by hg2 (Initiate) on Mar 03, 2015 at 15:19 UTC |