One solution would be to use a custom subroutine instead of print()ing
directly.  If you need something more robust, there are modules out
there that can do the heavy lifting for you.


#####################

use strict;
use warnings;
open(OUTFILE,">script.log") || die "Couldn't write to script.log!\n";

PrintOut("This goes to a file as well as the screen.\n");

sub PrintOut{
   print @_;
   print OUTFILE @_;
}

#####################





-----Original Message-----
From: Larry Guest [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 11, 2005 3:40 PM
To: 'Perl Beginners Mailing List'
Subject: Write stdout to a file as well as stdout

I have a script that does all kinds stuff.
When its running it outputs all kinds of useful information to the
screen and exits.

What I want to do is have this also sent to a file.

[Tim Johnson] <snip>


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to