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

Answer: how do i trap the error generated by perl

by arturo (Vicar)
on Jun 08, 2001 at 01:25 UTC ( #86760=categorized answer: print w/replies, xml ) Need Help??

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

Using eval {}; and $@ (which, if set, contains the error message that would otherwise be fatal -- see perldoc perlvar) will allow you to catch most errors:

eval { #code you want to catch errors from }; custom_error_handler($@) if $@;

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[choroba]: which lessons?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-09-25 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (279 votes). Check out past polls.

    Notices?