make sure $@ is localized for evals

as perl "Modern Perl"
This commit is contained in:
William Travis Holton 2011-11-27 14:46:51 +13:00
parent e9eacc69d8
commit 6c886e2864

View File

@ -47,10 +47,11 @@ snippet xunless
${1:expression} unless ${2:condition};${3} ${1:expression} unless ${2:condition};${3}
# Try/Except # Try/Except
snippet eval snippet eval
local $@;
eval { eval {
${1:# do something risky...} ${1:# do something risky...}
}; };
if ($@) { if (my $e = $@) {
${2:# handle failure...} ${2:# handle failure...}
} }
# While Loop # While Loop