How do you 'tee' the STDOUT?
# replicate everything that goes to STDOUT to a file too (uses a forked subprocess) use autodie; sub tee { my ($filename) = @_; open my $origstdout, '>&STDOUT'; open my $fh, ">$filename"; if (!open STDOUT, '|-') { ## child process while (sysread(STDIN, my $buffer, 1024)) { syswrite($origstdout, $buffer); syswrite($fh, $buffer); } exit; } ## parent process continues on and returns close $origstdout; close $fh; }