in reply to
writing in 2 handles
For the Windows challenged: This will do pretty much all that is to be done. *inx has a standard tee function.
# tee program
# quick tool by Marshall 7/2007
use strict;
use warnings;
sub usage ()
{
print "TEE USAGE:\n tees stdout to a file and to stdout\n".
" program | tee outfile\n".
" sends stdout from program to outfile\n";
exit;
}
my $filename = shift @ARGV;
usage unless $filename;
open (OUTFILE, ">$filename")
or (die "Can't open OUTFILE: $!");
while (<>)
{
print;
print OUTFILE;
}
close OUTFILE;
1;
Adapt to your needs, re: different FILEHANDLES or use IO::Tee