eval { # code that might die } if ($@) { # $@ contains your exception }