Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: error handling

by Zaxo (Archbishop)
on Jun 28, 2003 at 02:57 UTC ( #269795=note: print w/replies, xml ) Need Help??

in reply to error handling

You're describing a typical try ... catch situation. Have the error die with the message, call with eval {}, and check $@ after eval returns.

After Compline,

Replies are listed 'Best First'.
Re: Re: error handling
by archon (Monk) on Jun 28, 2003 at 03:11 UTC

    i must have been overanalyzing the problem from the start. i don't know why i didn't think of that.

    i did attempt the try...catch thing with but it stopped me from doing a return within the block.

      This is the mechanism used by under the hood, more or less. While is a much prettier interface than checking $@ yourself, it has some drawbacks. Since the arguments to both try and catch are anonymous subs, return will return from those and not from the enclosing sub, as you've experienced. You'll have to set up a variable with the value you want to return and then do so outside of try/catch.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2023-02-07 15:52 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (40 votes). Check out past polls.