in reply to Reopening STDOUT
There are several ways to do this.
1. My favorite, localize STDOUT in a block,
{ open local(*STDOUT), '>', '/dev/null' or die $!; #... close STDOUT or die $!; } # STDOUT is restored here
2. Open a different filehandle and select it to be the default output filehandle,
open NIL, '>', '/dev/null' or die $!; select NIL; #... select STDOUT; close NIL or die $!;
3. Duplicate STDOUT to some other handle *OLDSO, open STDOUT, print things, close STDOUT, duplicate *OLDSO to STDOUT, close *OLDSO. I don't like this one, too fussy.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reopening STDOUT ([open])
by tye (Sage) on Oct 10, 2003 at 20:45 UTC | |
by Anonymous Monk on Oct 10, 2003 at 21:18 UTC |