in reply to Re: Reopening STDOUT
in thread Reopening STDOUT
Your favorite trick can break some things. I just avoid copying or localizing globs that contain open file handles as I find there are too many egde cases where things break.
I much prefer to use the technique documented directly in the open documentation. Here is a modified version of it that doesn't bother with STDERR:
You can use a non-bareword file handle in place of OLDOUT, if you prefer.open( OLDOUT, ">&STDOUT" ); open( STDOUT, '> foo.out' ) or die "Can't redirect STDOUT to foo.out: $!\n"; # this works for subprocesses and C code too: print "stdout 1\n"; close( STDOUT ); open( STDOUT, ">&OLDOUT" ); close( OLDOUT );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^2: Reopening STDOUT ([open])
by Anonymous Monk on Oct 10, 2003 at 21:18 UTC |