in reply to Redirecting STDOUT to file and screen as an afterthought, on Windows.

Pardon my stupidity, but why can't you just copy your code into a text editor and replace all instances of print with print $tee? It would only take about 10 seconds, though I admit that the above suggested methods are probably more elegant.
  • Comment on Re: Redirecting STDOUT to file and screen as an afterthought, on Windows.

Replies are listed 'Best First'.
Re^2: Redirecting STDOUT to file and screen as an afterthought, on Windows.
by spikey_wan (Scribe) on Nov 04, 2004 at 10:44 UTC
    How would you do that if the user turns the log_to_file switch on, does some stuff, then turns the log_to_file switch off?

    You'd have to duplicate every print command, like this:

    if ($tee) { print $tee "What did I want to say?\n" } else { print "What did I want to say?\n" }