in reply to Re^2: Copy STDOUT and STDERR to logfile and also display to screen
in thread Copy STDOUT and STDERR to logfile and also display to screen

Thanks for the tip on the sub.

regarding your other comment: It works, but now you've got two copies of every message

Could you please explain what do you mean by copy? it writes the same msg twice but it does it in two different places...the output on the screen will not have dups and the output in the log will not have dupliactes...

if you say it is inefficient to do it this then i would agree but i am not sure whether i understand the term "copy" there.

thanks

SK

  • Comment on Re^3: Copy STDOUT and STDERR to logfile and also display to screen

Replies are listed 'Best First'.
Re^4: Copy STDOUT and STDERR to logfile and also display to screen
by Fletch (Bishop) on Aug 10, 2005 at 18:23 UTC

    In your code you have to duplicate two copies of every message you print in your source; if you ever need to change the output you'd have to edit each copy of each pair of prints. It's left as an exercise to imagine the fun that commences when one or more inevitably gets out of sync and you have different results in different places for the "same" output. To say nothing of 7 months down the line when marketing wants the output also sent to a third and fourth place . . .

    Using the subs (or the IO::Tee module or tee externally) you have to change just one string to affect the output to every destination.

    --
    We're looking for people in ATL

      Gotcha! Thanks, I was not thinking about maintenance/change, which i will try to next time when i post