<?xml version="1.0" encoding="windows-1252"?>
<node id="629680" title="Nested evals - are they evil?" created="2007-07-30 18:34:17" updated="2007-07-30 14:34:17">
<type id="115">
perlquestion</type>
<author id="61104">
cLive ;-)</author>
<data>
<field name="doctext">
&lt;p&gt;I'm gradually taking over responsibility of a codebase that uses nested evals quite a bit. Sort of like this:&lt;/p&gt;
&lt;code&gt;
eval
{
    callMethod();
};
if ($@)
{
    confess "CallMethod failed: $@";
}
&lt;/code&gt;
&lt;p&gt;with callMethod() having another one embedded, eg&lt;/p&gt;
&lt;code&gt;sub callMethod
{
    # blah blah
    eval {
        someMoreCode();
    };
    if ($@)
    {
        confess "someMoreCode failed: $@";
    }
}
&lt;/code&gt;
&lt;p&gt;The impression I get is that some error checking is missing and this is a rough and ready way of dealing with fatal errors. It works, but for some reason, it makes me feel uncomfortable.&lt;/p&gt;
&lt;p&gt;My instinct is telling me to get rid of these evals (while fixing exception handling), but am I just making work for myself? Or &lt;b&gt;should I be embracing this exception handling technique as a tool for faster development?&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;edit - added bold ;-)&lt;/p&gt;
&lt;p&gt;edit 2 - yes, the confesses were originally dies (so that explains quite a bit right there :)</field>
</data>
</node>
