Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Multiplexing STDOUT and STDERR

by demerphq (Chancellor)
on Nov 13, 2003 at 00:00 UTC ( [id://306681]=note: print w/replies, xml ) Need Help??


in reply to Multiplexing STDOUT and STDERR

Its interesting, but I have a module that I wrote for work that does pretty close to exactly what you ask for here. The job is indeed trickier than it looks. The approach I took was to tie duped STDOUT and STDERR filehandles, and then intercept warnings and dies through a SIG handler (which can be problematic according to the docs, but not so far for me.) This works with the majority of code, but things that also play games with these filehandles can mess things up. Thankfully they seem to be rare.

Incidentally I too started with IO::Tee, and it worked (with added sig handlers), but as I started adding hooks and dealing with issues ($SIG{__DIE__} will be called even inside an eval is an example, albeit not that good a one) it soon became easier not to bother.

HTH


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi


Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found