Subject: | can't set STDERR to an IO::Tee object |
redirecting stderr to an io::tee object causes stderr output to disappear
this code (stderr.t) produces the following output:
#!/usr/bin/perl -w
use Test::More (tests => 4);
use IO::Tee;
use IO::File;
stderrtest(new IO::File(">teebug1.out"));
stderrtest(new IO::Tee(\*STDOUT, ">teebug1.out"));
sub stderrtest
{
my $io = shift;
open(STDERR, ">&", $io);
print STDERR "\nSTDERR: output\n";
select $io;
print "plain test.\n";
my $filecontents = `cat teebug1.out`;
ok($filecontents =~ /plain/m);
ok($filecontents =~ /STDERR/m, 'STDERR');
}
output:
1..2
ok 1
ok 2 - STDERR
plain test.
ok 3
not ok 4 - STDERR
# Failed test (stderr.t at line 22)
This is perl, v5.8.1 built for i686-linux-thread-multi
Linux codemasters 2.4.21-4.ELsmp #1 SMP Fri Oct 3 17:52:56 EDT 2003 i686 i686 i386 GNU/Linux