in reply to Evaluate success or failure of a subroutine
The usual approach is to use die() instead:
sub some_sub { die "Error" if ($some_condition); } eval { my $value = some_sub(); # do stuff with $value }; if (my $exception = $@) { # exception! handle error here }
|
|---|