If you were using Test::More, this would be easy and documented. The output handle is set by the internal Test::Builder object which itself has the methods ->output( $fh ), ->failure_output( $fh ), and ->todo_output( $fh ) to set the various filehandles.
Here is an example from one of my scripts which shows test output being captured.
use Test::More; use vars qw( $TEST_OUTPUT ); main( @ARGV ); exit 0; sub main { intialize( @_ ); ok( ... ); print $TEST_OUTPUT; 1; } sub initialize { $| = 1; open my $fh, ">", \ $TEST_OUTPUT or die; my $b = Test::More->builder; $b->output( $fh ); $b->failure_output( $fh ); $b->todo_output( $fh ); 1; }
In reply to Re: Redirecting STDOUT from internal function with 5.6.1 restrictions
by diotalevi
in thread Redirecting STDOUT from internal function with 5.6.1 restrictions
by mgc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |