unless (eval { # <-- "try" do_something_that_might_die(); 1; }) { # <-- "catch" my $error=$@; # check $error # then die or fix / workaround the problem }