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

Re: Why $@ makes me cry

Thread Previous
From:
Dr.Ruud
Date:
June 21, 2008 04:45
Subject:
Re: Why $@ makes me cry
Message ID:
20080621114550.9187.qmail@lists.develooper.com
Paul Fenwick wrote:
> David Nicol:

>> How hard would it be to defer destruction of lexicals within evals
>> until the statement containing the eval ends?  What if anything would
>> that break?
>
> Consider the following code:
>
>      while (my $spy = detect_intruders()) {
>
>          eval {
>              my $robbie = Killer::Robot->new;
>              $robbie->attack($spy);
>              1;
>          } or do {
>              say "You win this time, $spy!";
>              make_hasty_retreat();
>          }

Missing semicolon.

>
>          my $cleaners = Professional::Cleaners->new;
>
>          $cleaners->steam_clean($secret_underground_base);
>
>      }
> [...]
>
> However I believe there may be some merit in saving $@ before a
DESTROY is
> called

  push @@, $@ if $@;

-- 
Affijn, Ruud

"Gewoon is een tijger."


Thread Previous


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