Created
August 8, 2019 05:57
-
-
Save andrewsolomon/e43522deebd71c6539ed12026f82788b to your computer and use it in GitHub Desktop.
use Perl's eval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
sub oops { | |
die "It happened"; | |
} | |
# Instead of just | |
# | |
# say oops(); | |
eval { | |
say oops(); | |
}; | |
if ($@) { | |
say "Caught it!"; | |
} | |
# This code isn't reached without encosing the call to oops() in an eval | |
say "I got to the end"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment