eval { # Code which might generate an error } if ($@) { # Handles any errors here # $@ holds the error message }