wow, I see it now. Thanks for that huge tip.
There seems to be some problem when setting it just for the $tee though, write() seems to expect $~ and $^ to be filled in too , otherwise it keeps trying to use the name of the filehandle IO::<something> which obviously won't work.
After setting $^ and $~ properly before write() then write began spitting out duplicate lines each time it was called. With each successive call to write, write() would output the previous line and the current line.
to solve this I cleared the accumulator ( $^A = '' ) after writing each line. That solved the problem.
sub print_clean_stdout {
my $result = shift;
$check_description = shift;
$check_result = shift;
$severity_w = shift;
if ( $result eq 'FAIL' ) {
$tee->format_write( q/main::FAIL/ );
$~ = 'FAIL';
$failures++;
}
else {
$tee->format_write( q/main::STD/ );
$~ = 'STD';
$successes++;
}
write;
$^A = ''; # we have to mess with the accumulator
}