in reply to Evaluate success or failure of a subroutine

You can't stop an exit, but you can catch the return code using my $ret = system("$0 arguments") or something like it.

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 }