eval { ... code that might die ... }; if ($@) { # if we had an error. ... read $@ and decide on what to do ... }