http://www.perlmonks.org?node_id=625932


in reply to Perl Test - Capture print statements

You could localize STDOUT, opening it to a variable.

my $out = do { my $msg; open local( *STDOUT), '>', \$msg or die $!; mytest(); $msg };
That takes Perl 5.8+ for opening a handle to a variable.

++fenLisesi caught a thinko in text, s/STDERR/STDOUT/. Repaired.

After Compline,
Zaxo