Another suggestion. Use PerlIO::Util's tee layer:
#!/usr/bin/perl use strict; use warnings; use PerlIO::Util; *STDOUT->push_layer(tee => \my $capture_buf); print "hello world\n"; print STDERR "captured STDOUT: '$capture_buf'"; __END__ $ ./819527.pl hello world captured STDOUT: 'hello world '
In reply to Re: Copy contents of STDOUT
by almut
in thread Copy contents of STDOUT
by perl_is_fun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |