Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2016-05-25 04:12 GMT
Find Nodes?
    Voting Booth?