Created
June 19, 2012 20:16
-
-
Save 2shortplanks/2956282 to your computer and use it in GitHub Desktop.
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 5.016; | |
use warnings; | |
use Try::Tiny; | |
try { | |
die "Boom Boom"; | |
} catch { | |
given ($_) { | |
when (/Boom/) { | |
try { | |
die "Shake shake the room" | |
} catch { | |
say STDERR $_; | |
} | |
} | |
} | |
} | |
# THIS PRINTS OUT "Boom Boom"! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
given introduces lexical $_ which is closed over by the anonymous subroutine passed to catch which obscures the global $_ that the catch routine populates
i.e. it does the wrong thing for horrifically complex reasons