eval {
    $x = 1 / 0; #generate a divide by zero exception
};

if ($@) { #will be true, actually the error, if an exception
    print "Something went wrong: $@\n";
    exit(1); #and exit with an error status
}
