eval { # your code that may die }; if ( $@ ) { your_error_catcher( $@ ); }