use Try::Tiny; # handle errors with a catch handler try { die "foo"; } catch { warn "caught error: $_"; # not $@ }; # or use Syntax::Keyword::Try; sub foo { try { attempt_a_thing(); return "success"; } catch { warn "It failed - $@"; return "failure"; } }