Or, without using tie:
open my $oldout, ">&STDOUT" or die "Can't dup STDOUT: $!"; my $stdout; close STDOUT; open STDOUT, ">", \$stdout or die $!; # This is where the magic happen +s print "foo\n"; close STDOUT; open STDOUT, ">&", $oldout or die $!; print "Done fooling around\n"; print $stdout; # foo
This is mostly copy & pasted from open, so you might want to look there for more.
In reply to Re^2: String Buffer
by FunkyMonk
in thread String Buffer
by kayos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |