in reply to Building a log file

Sure, perl $yourscript.pl | tee logfile.

You can also duplicate the STDOUT file handle as described in perlopentut or open.

Replies are listed 'Best First'.
Re^2: Building a log file
by Marshall (Canon) on Jun 23, 2009 at 15:20 UTC
    This is a good idea. Windows systems don't have tee, I hacked in this tee.pl awhile ago for my Windoze work. It is a simple program. The only tricky part is turning auto-flush on for write. Have fun to anybody who needs it.
    #!/usr/bin/perl -w use strict; # tee program #### tee.pl ###### # quickie tool $| =1; #flushes I/O for each write. sub usage { print "TEE USAGE:\n tees stdout to a file and to stdout\n". " program | tee outfile\n"; } my $filename = shift @ARGV; usage unless $filename; open (OUTFILE, '>', "$filename") or (die "Can't open OUTFILE: $!"); while (<>) { print; print OUTFILE; }