General Perl Best Practice stuff: uncuddle "else", localise $@
use $exception in place of $e
This commit is contained in:
parent
cca1deb78c
commit
af9f42c539
@ -4,7 +4,8 @@
|
|||||||
snippet ife "Conditional if..else (ife)"
|
snippet ife "Conditional if..else (ife)"
|
||||||
if ($1) {
|
if ($1) {
|
||||||
${2:# body...}
|
${2:# body...}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
${3:# else...}
|
${3:# else...}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,9 +14,11 @@ endsnippet
|
|||||||
snippet ifee "Conditional if..elsif..else (ifee)"
|
snippet ifee "Conditional if..elsif..else (ifee)"
|
||||||
if ($1) {
|
if ($1) {
|
||||||
${2:# body...}
|
${2:# body...}
|
||||||
} elsif ($3) {
|
}
|
||||||
|
elsif ($3) {
|
||||||
${4:# elsif...}
|
${4:# elsif...}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
${5:# else...}
|
${5:# else...}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,11 +77,12 @@ ${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new {
|
|||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet eval "eval"
|
snippet eval "eval"
|
||||||
|
local $@;
|
||||||
eval {
|
eval {
|
||||||
${1:# do something risky...}
|
${1:# do something risky...}
|
||||||
};
|
};
|
||||||
if ($@) {
|
if (my $${2:exception} = $@) {
|
||||||
${2:# handle failure...}
|
${3:# handle failure...}
|
||||||
}
|
}
|
||||||
|
|
||||||
endsnippet
|
endsnippet
|
||||||
|
Loading…
x
Reference in New Issue
Block a user