eval { # here we try do_smth() } or { # here we catch ... } #### # Try clause my ($error1, $error2); { local $@; unless (eval { ...; return 1 }) { $error1 = 1; $error2 = $@; } } # Catch clause if ($error1) { # handle exception }