Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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 studying the Monastery: (10)
As of 2014-10-23 18:19 GMT
Find Nodes?
    Voting Booth?

    For retirement, I am banking on:

    Results (126 votes), past polls