I'm in a dilemma here. At work, we have a lot of C programmers, and hence they like to code their Perl code in sort of a C-ish way. Which is fine in most cases, but there's one thing that I just fail to see the benefit, and that is an idiom that they use:
sub myfunc { ... return eval { # do bunch of things here... if($err_condition) { die "error"; } return 1; } }
So basically they want to make it such that you can check the return value and check $@ in an errono-like fashion. Which is fine, but it just strikes me as really, really odd.
I just fail to see how it could be better than just simply raising an exception. Why can't I just die()?
If I'm to try and use a simple die/croak instead, I'm going to have to convince a lot of people... Otherwise if I'm going to have to live with it, I want to make sure that I understand the benefits, and that we're not alone in using this.
In all honesty, I may just be too deep into all the Perl-isms, and that I'm missing something obvious. If there are other people who use this idiom, I would realy like to know, and also, why? What advantages do you gain?
TIA.
In reply to return eval { die() } idiom by lestrrat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |