Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: how do i trap the error generated by perl

by LuTze (Initiate)
on Feb 09, 2010 at 17:15 UTC ( [id://822240]=note: print w/replies, xml ) Need Help??


in reply to how do i trap the error generated by perl

bikeNomad's answer is correct, with an addendum.

Using signals is not always straightforward. Signals are handled asynchronously and can interrupt each other. If you are, for example, redirecting those messages to a file, one signal might come in while the previous one is still processing, and stop it from going any further. You could loose some warnings that way, especially if they are being emitted from a tight loop and the handler is slow to execute.

In this case, it may be easier to redirect STDERR, which can be done with something like:

my $old_stderr = STDERR; open STDERR, ">mylogfile.log";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found