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

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); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://629716]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2018-01-21 09:05 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.