Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: canonical doc explaing need for "eval { ... } or do {...}" construct

by cavac (Parson)
on May 10, 2022 at 07:57 UTC ( [id://11143733]=note: print w/replies, xml ) Need Help??


in reply to canonical doc explaing need for "eval { ... } or do {...}" construct

Personally, i usually use something like this:

use English; ... my $evalok = 0; eval { SOME_RISKY_CODE $evalok = 1; }; if(!$evalok) { print "Something bad happened: ", $EVAL_ERROR, "\n"; work_around_the_problem_or_give_up(); }

This may be a good or bad solution. But at least for me, it makes it easier and faster to visually scan the code later in its life cycle and see how it's meant to flow and if there is error handling in place.

perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found