Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: writing in 2 handles

by Marshall (Abbot)
on May 16, 2010 at 22:02 UTC ( #840264=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://840264]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-02-24 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (310 votes). Check out past polls.

    Notices?