eval { # do something that might raise a fatal error }; if ( $@ ) { # do something to report the error # $@ contains the error message or error object }