Subject: | IO::Tee incompatibe with format/write |
see attached format.t. here's the output:
1..4
ok 1
write() on unopened filehandle GEN1 at format.t line 48.
not ok 2
# Failed test (format.t at line 51)
ok 3
Undefined format "Symbol::GEN5" called at format.t line 34.
# Looks like you planned 4 tests but only ran 3.
# Looks like your test died just after 3.
Attempt to free unreferenced scalar during global destruction.
#!/usr/bin/perl -w
use Test::More (tests => 4);
use IO::Tee;
use IO::File;
format MYFORMAT =
@<<<<<<<<<<<<<<<<<<
$<,
.
test_using_globals(new IO::File('>teebug1.out'));
unlink 'teebug1.out';
#this generates a write() on unopened filehandle GEN1 error
test_using_globals(new IO::Tee(">teebug1.out", ">teebug2.out"));
unlink 'teebug1.out';
unlink 'teebug2.out';
test(new IO::File('>teebug1.out'));
unlink 'teebug1.out';
#this one causes Undefined format "Symbol::GEN5" called
test(new IO::Tee(">teebug1.out", ">teebug2.out"));
unlink 'teebug1.out';
unlink 'teebug2.out';
sub test
{
my $io = shift;
$io->format_name('MYFORMAT');
select $io;
write;
my $filecontents = `cat teebug1.out`;
ok($filecontents =~ /\s+/);
}
sub test_using_globals
{
my $io = shift;
$io->format_name('MYFORMAT');
select $io;
$~ = 'MYFORMAT';
write;
my $filecontents = `cat teebug1.out`;
ok($filecontents =~ /\s+/);
unlink 'teebug2.out';
}