On Fri, Mar 28, 2014 at 3:05 PM, Dr.Ruud <rvtol+use...@isolution.nl> wrote:
> if ($@) { >> die "$@"; >> } >> > > Never test $@, only use the value of $@ after a failed eval. > Why not? The perldoc eval shows: If the code to be executed doesn't vary, you may use the eval-BLOCK form to trap run-time errors without incurring the penalty of recompiling each time. The error, if any, is still returned in $@. Examples: # make divide-by-zero nonfatal eval { $answer = $a / $b; }; warn $@ if $@; # same thing, but less efficient eval '$answer = $a / $b'; warn $@ if $@; # a compile-time error eval { $answer = }; # WRONG # a run-time error eval '$answer ='; # sets $@ -- a Andy Bach, afb...@gmail.com 608 658-1890 cell 608 261-5738 wk