Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Drawback of eval {---}if ($@){---}, when using many times?

by shmem (Chancellor)
on Oct 29, 2015 at 13:47 UTC ( [id://1146377]=note: print w/replies, xml ) Need Help??


in reply to Re: Drawback of eval {---}if ($@){---}, when using many times?
in thread Drawback of eval {---}if ($@){---}, when using many times?

Yes, but!

sub perform { my $code = shift; my $result = eval { $code->(@_) }; if( $@ ) { ... # error handling } else { return $result; } };

looks more flexible to me, since that way you can pass arguments for the subs to the dispatcher (e.g. error displayed), and you get something back for so much carefulness.

update: This is a good example for following the DRY principle - Don't Repeat Yourself.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-25 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found