use 5.8.0; # for open \$buf. use strict; use warnings; use IO::Tee (); my $stdout = ''; { my $fh_scalar; open($fh_scalar, '>', \$stdout) or die("Can't open \$stdout: $!\n"); local *STDOUT = new IO::Tee( \*STDERR, $fh_scalar ); print("Test\n"); } print("\n"); print("\$stdout:\n"); print($stdout);
I added local to easily restore the original STDOUT, but it's not needed.
In reply to Re^2: Tee STDOUT
by ikegami
in thread Tee STDOUT
by water
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |