eval { foo(); }; print "caught '$@'\n" if $@; sub foo { # "throw" an error die "oops!"; }