Promising. But can I drop the wrapping sub by eval'ing
the 'die' directly?
I also need to have a useful returned val on success.
With that, I'll need to reverse the return logic.
Is there any hope for an approach like this?
# MAIN
unless ($result = my_sub($val1, $val2)) {
my $err_str = $@;
# handle error based on $err_str
}
# do wonderful things with $result
sub my_sub {
my ($param1, $param2) = @_;
# do stuff
if ($bad_data) {
eval {die "bad data"}; # ???
return undef;
}
# do more stuff
if ($useless_param2) {
eval {die "useless param 2"}; # ???
return undef;
}
# finish doing stuff
return $useful_result;
}