youngh has asked for the wisdom of the Perl Monks concerning the following question:
testing stdout capture 1 testing stdout capture 2Is this a bug in perl 5.8.6?
#!/usr/bin/perl -w use strict; use FileHandle; open SAVED_STDOUT, ">&STDOUT" or die "couldn't save STDOUT: $!\n"; open SAVED_STDERR, ">&STDERR" or die "couldn't save STDERR: $!\n"; print SAVED_STDOUT ""; # to suppress warning about possible typo my $captured_output = ""; close STDOUT; open STDOUT, ">", \$captured_output or die "couldn't re-open STDOUT: $ +!\n"; close STDERR; open STDERR, ">&STDOUT" or die "couldn't re-open STDERR: $!\n"; print "testing stdout capture 1\n"; print STDERR "testing stderr capture\n"; print "testing stdout capture 2\n"; close STDOUT; open STDOUT, ">&SAVED_STDOUT"; close STDERR; open STDERR, ">&SAVED_STDERR"; print STDERR $captured_output, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: possible bug in opening file handle to variable
by ikegami (Patriarch) on May 18, 2005 at 21:27 UTC | |
by Sandy (Curate) on May 19, 2005 at 17:16 UTC | |
by ikegami (Patriarch) on May 19, 2005 at 17:57 UTC | |
|
Re: possible bug in opening file handle to variable
by scmason (Monk) on May 18, 2005 at 22:03 UTC | |
|
Re: possible bug in opening file handle to variable
by Animator (Hermit) on May 19, 2005 at 10:22 UTC | |
|
Re: possible bug in opening file handle to variable
by Robertn (Hermit) on May 19, 2005 at 06:58 UTC | |
|
Re: possible bug in opening file handle to variable
by youngh (Novice) on May 19, 2005 at 18:45 UTC |