develooper Front page | perl.perl5.porters | Postings from June 2008

Re: Generic system() replacements

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
June 20, 2008 00:58
Subject:
Re: Generic system() replacements
Message ID:
20080620075829.GS25433@klangraum.plasmasturm.org
* Paul Fenwick <pjf@perltraining.com.au> [2008-06-20 00:50]:
> Am I missing something really important here? Is it important
> enough that we should be changing documentation?

There are various cases in which $@ can be swallowed before you
get to the `if` condition. There was some constellation with
exceptions in `DESTROY` in objects going out of scope at the end
of the `eval` block and other cases as “interesting” as that one.
Nested evals also have problems, I think. I didn’t commit all the
details to memory, unfortunately.

In any case the bottom line is that the only 100% reliable
indicator for whether an `eval` block executed without throwing
an exception is whether it returned undef (and you have to ensure
manually that successful execution results in some return value
other than undef).

You obviously already know about another fun case, which is
exception objects clearing themselves out of $@ as a side effect
of being checked for truthiness.

I have said before that I should trawl my mailing list archives
someday for all the cases people have discovered and then attempt
to write Unbreak::Eval.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About