From af9f42c53901810753b38de8643319249e863655 Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Mon, 2 Dec 2013 07:54:31 +1300 Subject: [PATCH 1/2] General Perl Best Practice stuff: uncuddle "else", localise $@ use $exception in place of $e --- UltiSnips/perl.snippets | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/UltiSnips/perl.snippets b/UltiSnips/perl.snippets index 720b7c8..e4f4ba8 100644 --- a/UltiSnips/perl.snippets +++ b/UltiSnips/perl.snippets @@ -4,7 +4,8 @@ snippet ife "Conditional if..else (ife)" if ($1) { ${2:# body...} -} else { +} +else { ${3:# else...} } @@ -13,9 +14,11 @@ endsnippet snippet ifee "Conditional if..elsif..else (ifee)" if ($1) { ${2:# body...} -} elsif ($3) { +} +elsif ($3) { ${4:# elsif...} -} else { +} +else { ${5:# else...} } @@ -74,11 +77,12 @@ ${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new { endsnippet snippet eval "eval" +local $@; eval { ${1:# do something risky...} }; -if ($@) { - ${2:# handle failure...} +if (my $${2:exception} = $@) { + ${3:# handle failure...} } endsnippet From 7265bcb5c136d7d45f974154102c8482eb7dd04b Mon Sep 17 00:00:00 2001 From: Travis Holton Date: Mon, 2 Dec 2013 20:26:55 +1300 Subject: [PATCH 2/2] use parent in place of "base" --- UltiSnips/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/perl.snippets b/UltiSnips/perl.snippets index e4f4ba8..9202915 100644 --- a/UltiSnips/perl.snippets +++ b/UltiSnips/perl.snippets @@ -65,7 +65,7 @@ endsnippet snippet class "class" package ${1:ClassName}; -${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new { +${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new { my $class = shift; $class = ref $class if ref $class; my $self = bless {}, $class;