make sure $@ is localized for evals
as perl "Modern Perl"
This commit is contained in:
parent
e9eacc69d8
commit
6c886e2864
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user