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.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^2: interleaf stdout stderr to a file
by hg2 (Initiate) on Mar 03, 2015 at 15:19 UTC
    an interesting solution. did not know stderr was unbuffered by default as looking at the output i originally had it looked to be buffered. thanks...