Front page | perl.beginners |
Postings from April 2012
Re: foreach and next
Thread Previous
|
Thread Next
From:
Shlomi Fish
Date:
April 8, 2012 07:38
Subject:
Re: foreach and next
Message ID:
20120408173823.46bb101c@lap.shlomifish.org
Hi Vyacheslav,
On Sun, 08 Apr 2012 15:10:06 +0000
Vyacheslav <agapov.slava@gmail.com> wrote:
> Thanks all.
>
> using eval helped me.
>
The problem with eval in Perl 5 is that it catches any and all thrown exceptions
. I.e: by default, it doesn't do Object-Oriented exceptions like Java, Ruby,
Python and other languages do, though this can be done to a large extent
using some CPAN modules. As a result, by using eval, you risk easily trapping
other more meaningful exceptions, which *should* cause your program to
terminate.
In your case, you're throwing an exception explicitly upon failure, so if you're
not interested in an exception getting thrown, you should just handle the
failure differently.
( I also recall seeing something about excessive exceptions throwing and
trapping being costly in CPU time, but this shouldn't make a difference in this
case. )
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Why I Love Perl - http://shlom.in/joy-of-perl
“Interesting” has a negative correlation with “successful”.
— Anno on Freenode's #perl
Please reply to list if it's a mailing list post - http://shlom.in/reply .
Thread Previous
|
Thread Next