Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Capturing both STDERR and STDOUT without shell redirect

by Narveson (Chaplain)
on Aug 06, 2009 at 21:31 UTC ( [id://786598]=note: print w/replies, xml ) Need Help??


in reply to Capturing both STDERR and STDOUT without shell redirect

Here's some code I've used that implements nimdokk's suggestion above:

open my $log_writer, '>>', $log_file; *STDOUT = $log_writer; *STDERR = $log_writer;

where of course you have to set $log_file first. I liked this approach enough to put it in the import sub of a module I named Log::Simple.

I'm sure there are better implementations of this idea on CPAN.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://786598]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-28 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found