Courage has asked for the wisdom of the Perl Monks concerning the following question:
perldoc -f open explains:
In the 2-arguments (and 1-argument) form opening '-' opens STDIN and opening '>-' opens STDOUT.
I try following code (for perl-5.8.0) but do not succeed:
It does not print anything to STDOUT, while I'm expecting to see output for last two lines.$|=1; my $stdout=''; close STDOUT; open STDOUT, ">", \$stdout; print "this\n"; close STDOUT; open STDOUT, '>-'; print "that\n"; print "[$stdout]";
perl-5.6.1 produces same effect (but it's better to comment a line about opening STDOUT in-memory)
I tried perl on Windows and Linux --- same effect.
What do I do wrong?
Thanks in advance,
Courage, the Cowardly Dog
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I re-open STDOUT?
by broquaint (Abbot) on Aug 07, 2003 at 12:17 UTC | |
by Limbic~Region (Chancellor) on Aug 07, 2003 at 12:40 UTC | |
|
Re: How can I re-open STDOUT?
by Limbic~Region (Chancellor) on Aug 07, 2003 at 12:07 UTC | |
by Courage (Parson) on Aug 07, 2003 at 12:42 UTC | |
|
Re: How can I re-open STDOUT?
by leriksen (Curate) on Aug 08, 2003 at 01:01 UTC |