Please Help!

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I need to catch an error printed by a module that I use. the problem
with this module is apart from using a log it also prints certain
errors directly to STDERR.
I want to catch these errors being printed to STDERR and log it into my
own logfile.

Since this module is an API I cannot change it's log config.

How to use eval and $SIG to workaround this problem ? Or are
there any other solutions ?

Kindly guide me on this,

Re: Please Help!

On 1 Aug 2006 05:03:17 -0700, wrote:

Quoted text here. Click to load it

Yes, I do help!

->(map substr
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Re: Please Help!

Quoted text here. Click to load it

If it is really printing directly to STDERR then you can't. If it uses
warn/die then you can use $SIG/eval to catch the errors, but
you already knew that so I presume it isn't :).

Quoted text here. Click to load it

Open STDERR onto a string, like this:

    my $STDERR_LOG;
    open STDERR, '>', $STDERR_LOG or die "can't catch STDERR: $!";

Note this requires 5.6(.1?) to work right.

Anything printed to STDERR will go into that string. You may want to dup
stderr somewhere else first, so's you can put it back afterwards.


'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'

Please Help - Problem solved !!!

HI Michele and Ben,

Thanks for your help.

I am still figuring out Michele's solution, as I am just an amateur to

I found this solution : Using IO::Capture::Stderr - check CPAN

This can capture stdin,stdout,stderr and so on. Hope this is of info to

Thanks once again,

Re: Please Help!

Quoted text here. Click to load it

I'll bet you would get a lot more help if you put the subject of
your article in the Subject of your article.

    Tad McClellan                          SGML consulting                   Perl programming
    Fort Worth, Texas

Site Timeline