in reply to use 'select' to change default output handle for entire script

I suppose you could do something like:

open STDOUT, ">>&STDERR" or die "Cannot redirect STDOUT to STDERR. $!" +;
  • Comment on Re: use 'select' to change default output handle for entire script
  • Download Code

Replies are listed 'Best First'.
Re^2: use 'select' to change default output handle for entire script
by richz (Beadle) on Nov 19, 2004 at 14:38 UTC
    Hmm, but then if I really wanted to use STDOUT I'd have to reopen it right?
      Then first open a filehandle to your old STDOUT, before redirecting STDOUT:
      open OLDSTDOUT ">&STDOUT" or die "oops: $!"; open STDOUT ">&STDERR" or die "oops: $!"; print OLDSTDOUT "Still to STDOUT..\n";
      Paul