Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Nested evals - are they evil?

by snoopy (Deacon)
on Jul 31, 2007 at 00:47 UTC ( #629716=note: print w/ replies, xml ) Need Help??


in reply to Nested evals - are they evil?

Is all the use of eval/checking as gratuitous as the above - just calling confess to die with a backtrace?

You might be able to install Carp's confess method as your fatal error handler. Then you can eliminate the evals and checking code.

#!/usr/bin/perl # # Die with backtrace # use Carp; $SIG{__DIE__} = \&Carp::confess; callMethod(); sub callMethod { # blah blah someMethod(0); } Sub someMethod { 1/shift; }
Alternatively, you can set up local handlers and eliminate evals, on a case-by-case basis:
sub callMethod { local $SIG{__DIE__} = sub {confess ("error calling someMethod: $_[0] +")}; someMethod(0); }


Comment on Re: Nested evals - are they evil?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-08-01 08:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls