Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: How many different ways can Perl code fail?

by wol (Hermit)
on Jan 14, 2009 at 17:45 UTC ( #736298=note: print w/replies, xml ) Need Help??


in reply to Re^2: How many different ways can Perl code fail?
in thread How many different ways can Perl code fail?

Why is using $@ a bit unreliable?

Update: Just found that the answer to this is covered by the documentation of Devel::EvalError. A quick read seems to suggest that the issue can only arise if there's a DESTROY method which uses eval (however indirectly) and doesn't localise $@.

You'll have to decide whether that would be a problem for you...

--
use JAPH;
print JAPH::asString();

  • Comment on Re^3: How many different ways can Perl code fail?

Replies are listed 'Best First'.
Re^4: How many different ways can Perl code fail?
by ikegami (Pope) on Jan 14, 2009 at 18:00 UTC

    You'll have to decide whether that would be a problem for you...

    Not really. It's not like it's harder to handle the problem. I'd say it's even cleaner.

    eval { ... }; if ($@) { ... }

    vs

    eval { ...; 1 } or ...;

    and

    my $x = eval { ... }; if ($@) { ... }

    vs

    my ($x) = eval { ... } or ...;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://736298]
help
Chatterbox?
and the fog begins to lift...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2018-06-21 19:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (119 votes). Check out past polls.

    Notices?