See the documentation for eval.
eval { ## code that may throw errors }; if( $@ ) { ## Handle errors } [download]
In reply to Re: how to trap errors? by Fletch in thread how to trap errors? by redss