NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
critic to the rescue (Score:1)
The problem of needing to localise special variables is discussed in http://perldoc.perl.org/perlobj.html#Destructors [perl.org].
There is a P::C policy ErrorHandling::RequireCheckingReturnValueOfEval [cpan.org] that catches this programming mistake. Its documentation also offers an alternative approach where you don't need to mess with other people's destructors to make it work.
Re: (Score:1)
Did you mean to say
How? (Score:1)
Re: (Score:1)
Err. How what?
Just like he said.
Thanks (Score:1)
eval {} or do_something (Score:1)
Following the eval block with an "or" seems to be more reliable than using "
if ($@)" to check for an exception in an eval block, because an eval block (or even an eval EXPR) returns undef if there is a syntax error or runtime error or a die statement is executed (according to perldoc -f eval).eval {
my $obj = SomeClass->new();
die "Code Red!\n";