eval { ## code that may throw errors }; if( $@ ) { ## Handle errors }