[Top] [All Lists]

redirecting STDERR with IO::Tee

Subject: redirecting STDERR with IO::Tee
Date: Mon, 22 Jun 2009 10:53:06 -0700
Newsgroups: perl.beginners
I have a script which runs mostly via a cron job and sometimes interactively.  
I would like STDERR to automatically print to both the console and to a logfile 

Right now I've gotten as far as merging both file handles with IO::Tee but I'm 
not sure if I'm heading down the right path.
my $merged_stderr = IO::Tee->new( \*STDERR, new IO::File(">>$errlog") );

This only works when explicitely naming the file handle in a print statement.  
How can I take it to the next step, which is to have STDERR automatically print 
to that file handle? 

Any help would be appreciated.


<Prev in Thread] Current Thread [Next in Thread>