#file: tee.pl use strict; use warnings; $| = 1; # **** turn off output buffering ***** 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") || die "Can't open OUTFILE: $!"; while (<>){ print; print OUTFILE; }