in reply to Re: STDOUT redirect in Perl
in thread STDOUT redirect in Perl

You don't need to mess with typeglobs to do the second.
open(STDOUT, '> myfilename.txt'); #reopen STDOUT as a file print "This goes to the file\n";

Or
open(OUTFILE, '> myfilename.txt'); print "This goes to the screen\n"; open(STDOUT, '>&OUTFILE'); #dup STDOUT to OUTFILE print "This goes to the file\n";