As documented in open
use strict; use warnings; open my $fh, '>', \my $buffer or die "Can't open memory file: $!"; select $fh; foo(); bar(); print STDOUT "<buffered>\n$buffer</buffered>\n"; sub foo { print "Hello from Foo\n"; } sub bar { print "Hello from Bar\n"; } __END__
Update: Removed unnecessary reference to my $stdout = \*STDOUT; Thanks toolic.
In reply to Re: Collect prints to a string
by wind
in thread Collect prints to a string
by vit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |