On Dec 10, 12:57 pm, [email protected] (Shawn H Corey) wrote:
> C.DeRykus wrote:
> > On Dec 8, 1:57 am, [email protected] (C.DeRykus) wrote:
> >> On Dec 8, 12:08 am, [email protected] (Anders Hartman) wrote:
>
> >>> ...
>
> >> ...
> >> Also, in this case, I'd write the eval for compile-time and check
> >> for errors:
>
> >> eval { asub() };
> >> die $@ if $@;
>
> > No, sorry, that's a "useless use of eval" since you could just call
> > the sub directly. Since, the intent was to define and call the sub
> > dynamically though, checking for eval errors is still a good idea.
>
> No, it's not. If asub() has a die or it calls a sub that has one, this
> will catch the die. Also for croak, et al.
>
The confusion thickens because asub() wasn't dynamic here (even
though the OP intended it to be). I just tried to clarify that the
eval {}
wasn't needed without the dynamic sub. As you mention though, an
eval block could be useful in a scenario that required trapping fatal
errors.
--
Charles DeRykus
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/