in reply to How to restore from redirecting STDOUT to variable?
#!/usr/bin/perl use warnings; use strict; open my $save_out, '>&', \*STDOUT or die "Can't dup STDOUT: $!"; close STDOUT; my $output; open STDOUT, '>', \$output or die "Can't open STDOUT: $!"; print "test \n"; close STDOUT; open STDOUT, '>&', $save_out or die "Can't restore STDOUT: $!"; print "Back\n"; print $output;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to restore from redirecting STDOUT to variable?
by anaconda_wly (Scribe) on Jan 17, 2013 at 03:34 UTC | |
by Athanasius (Archbishop) on Jan 17, 2013 at 04:14 UTC | |
by mbethke (Hermit) on Jan 17, 2013 at 04:30 UTC | |
by anaconda_wly (Scribe) on Jan 17, 2013 at 06:01 UTC |