in reply to Re: STDOUT redirect in Perl
in thread STDOUT redirect in Perl
open(STDOUT, '> myfilename.txt'); #reopen STDOUT as a file print "This goes to the file\n";
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";
|
|---|