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

Re: Why $@ makes me cry

Thread Previous | Thread Next
From:
merlyn
Date:
June 25, 2008 18:18
Subject:
Re: Why $@ makes me cry
Message ID:
8663rx6lju.fsf@blue.stonehenge.com
>>>>> "Mark" == Mark Mielke <mark@mark.mielke.cc> writes:

Mark> Most people who run eval{} doesn't check for eval{} failing. They check for $@
Mark> being true. Whether $@ is true from eval{} catching an exception, or DESTROY
Mark> doing $@ .=, the resulting $@ is still true.

It's wrong to do $@ .= if you haven't seen whether $@ is an object or not.

But just to put my two cents into this thread, anything that breaks this
pattern:

        eval {
             ...
        };
        if ($@) {
             ... # something went wrong in eval block
        }

is clearly wrong.  And yes, I know a "local $@" inside that block already
breaks this, and I think that's a bug, but I don't know how to fix it
properly.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

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