in reply to Re: How to capture STDOUT/STDERR of a function
in thread How to capture STDOUT/STDERR of a function

Thanks, I didn't know about that. What I'm trying to do is to catch the output from Test::Harness, something like the following after your example:
use strict; use Test::Harness; my $out; { open local(*STDOUT),'>',\$out; runtests(); } print $out;
Somehow all results are still printed out to screen, not to the $out variable. I tried STDERR too, the same result. Thanks.

Replies are listed 'Best First'.
Re^3: How to capture STDOUT/STDERR of a function
by Zaxo (Archbishop) on Aug 31, 2004 at 18:13 UTC

    Your use of the idiom is correct. The trouble is that Test::Harness does its own IO remapping.

    You could try running tests from the command line and redirecting output from there.

    After Compline,
    Zaxo

Re^3: How to capture STDOUT/STDERR of a function
by johnnywang (Priest) on Aug 31, 2004 at 18:09 UTC
    Sorry, forgot to login for the above post.