On Dec 10, 12:57 pm, shawnhco...@gmail.com (Shawn H Corey) wrote:
> C.DeRykus wrote:
> > On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote:
> >> On Dec 8, 12:08 am, an...@melerit.se (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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to