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.
|
---|