On Thu, 28 Oct 1999, Public Interactive wrote:
> On 10/28/99 12:34 PM, Eric Cholet wrote:
> > You could use "eval" and "die", Perl's standard exception mechanism.
>
> I thought of that, but I was concerned that my module would suffer
> a performance hit. Granted, it's not a strong eval, but it just
> seems ugly. If that's the only way, I guess I'm stuck, but it seems
> to me that there should be some call like Apache->return(OK) or
> $r->return(OK) that I can call from any depth within a PerlHander
> that would behave as if handler() returned that value.
I'm pretty sure that there isn't any real performance hit for this (though
surely someone will correct me if I'm wrong).
eval in Perl has two more or less distinct functions.
One is take a string and evaluate it as code. This involves parsing the
code, compiling it, and then executing it. For obvious reasons, this can
be some serious overhead, depending on the complexity of the code being
eval'd.
The other is to take a block of code and trap fatal errors by putting them
into the $@ variable. I can't imagine that there is any major performance
hit from this. This code can all be compiled at compile time because it
is not being dynamically generated so there is not any parsing or
compiling going on, just the normal run time evaluation. Sticking a
scalar into $@ on a die should not be a big run-time performance hit, I
would think.
-Dave
/*==================
www.urth.org
we await the New Sun
==================*/