in reply to STDOUT redirect in Perl
open ( OUTFILE, '>myfilename.txt' ); print "This goes to the screen\n"; select ( OUTFILE ); print "This goes to the file\n";
The other method that works is using typeglobs.
open ( OUTFILE, '>myfilename.txt' ); print "This goes to the screen\n"; *STDOUT = *OUTFILE; print "This goes to the file\n";
Personally, I prefer the select method.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: STDOUT redirect in Perl
by Ven'Tatsu (Deacon) on Nov 14, 2001 at 08:58 UTC |