Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Error Handling Misconception

by aquarium (Curate)
on Sep 04, 2003 at 13:28 UTC ( [id://288857]=note: print w/replies, xml ) Need Help??


in reply to Error Handling Misconception

if i understand $@ correctly: it contains an error message for the "most recent" statement. in this case it's supposed to be the eval, but instead it's the assignment, which resets $@ to null. so the loop should be
while (eval { my $value = $object->next_val() }) { # do cool stuff } print "Error: $@\n" if($@);

Replies are listed 'Best First'.
Re: Re: Error Handling Misconception
by John M. Dlugosz (Monsignor) on Sep 04, 2003 at 14:54 UTC
    According to perlvar,

    $EVAL_ERROR
    $@
    The Perl syntax error message from the last eval() operator. If $@ is the null string, the last eval() parsed and executed correctly (although the operations you invoked may have failed in the normal fashion). (Mnemonic: Where was the syntax error ``at''?)

    Warning messages are not collected in this variable. You can, however, set up a routine to process warnings by setting $SIG{__WARN__} as described below.

    Also see Error Indicators.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://288857]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-29 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found