Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Answer: how do i trap the error generated by perl

( #822240=categorized answer: print w/ replies, xml ) Need Help??

Q&A > programs and processes > how do i trap the error generated by perl contributed by LuTze

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";

Comment on Answer: how do i trap the error generated by perl
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2014-08-21 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls