Think about Loose Coupling | |
PerlMonks |
Re: Multiplexing STDOUT and STDERRby demerphq (Chancellor) |
on Nov 13, 2003 at 00:00 UTC ( [id://306681]=note: print w/replies, xml ) | Need Help?? |
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.
In Section
Seekers of Perl Wisdom
|
|