You can die from anywhere in your sub. You can catch an error from a bunch of nested or strung-together calls. You get the message back without having to use return values. And you don't have to deal with the error until any number of layers.
For example:
eval{ my $a = b(); $a = c(); ## etc... }; if ($@){ print "This error happened: $@"; exit; } sub a{ open FILE, $file or die "File open error ($!)"; ## other similar stuff }
-- iakobski
In reply to Re: style for returning errors from subroutines
by iakobski
in thread style for returning errors from subroutines
by Boldra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |