From 6c886e2864287cfe64b17e93a4cb932e52046e75 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 27 Nov 2011 14:46:51 +1300 Subject: [PATCH 1/6] make sure $@ is localized for evals as perl "Modern Perl" --- snippets/perl.snippets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 78ec125..25b12a1 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -47,10 +47,11 @@ snippet xunless ${1:expression} unless ${2:condition};${3} # Try/Except snippet eval + local $@; eval { ${1:# do something risky...} }; - if ($@) { + if (my $e = $@) { ${2:# handle failure...} } # While Loop From 827755ad89b805a9b2fa4910a57195aa2ec2e6a3 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 08:58:12 +1300 Subject: [PATCH 2/6] subroutine pod snippet with "=cut" For when someone wants to put the pod next to the subroutine definition --- snippets/perl.snippets | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 25b12a1..9c40051 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -215,6 +215,15 @@ snippet psub ${2:Summary....} +# Heading for inline subroutine pod +snippet psubi + =head2 ${1:MethodName} + + ${2:Summary...} + + + =cut + # Subroutine signature snippet parg From a8e879d9d8cdc11f682dd0f58dc82d419c8dc7dc Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 09:02:04 +1300 Subject: [PATCH 3/6] Added a snippet for Test::Routine style tests Also put in a more descriptive comment for Test::Class related snippet --- snippets/perl.snippets | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 9c40051..05882db 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -310,7 +310,7 @@ snippet override # use test classes snippet tuse use Test::More; - use Test::Deep; + use Test::Deep (); use Test::Exception; # local test lib @@ -326,7 +326,7 @@ snippet trunner use ${1:test_class}; $1->runtests(); -#testclass +# Test::Class-style test snippet tsub sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) { my $self = shift; @@ -334,6 +334,12 @@ snippet tsub } +# Test::Routine-style test +snippet trsub + test ${1:test_name} => { description => '${2:Description of test.}'} => sub { + my ($self) = @_; + ${3:# test code} + }; #prep test method snippet tprep From fafa4a7147004fa43e7ba5d6df9031a7c58fef63 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 08:59:25 +1300 Subject: [PATCH 4/6] Cleanup - Moose parent class name should be enclosed in quotes --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 05882db..2670e49 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -267,7 +267,7 @@ snippet moosecl package ${1:ClassName}; use Moose; - #extends ${2:# ParentClass}; + #extends '${2:# ParentClass}'; ${6:# body of class} From 750f80fb7722cd3e2eedbf82dfd046a51db0257a Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 09:40:53 +1300 Subject: [PATCH 5/6] added myself to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 13cba33..e985d7e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,3 +34,4 @@ marutanm msanders Povilas Balzaravičius Pawka Dmitry Dementev +Travis Holton From 9a18690ef3c0d804cbdc97f3d5ba994a69e53acb Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 11:24:03 +1300 Subject: [PATCH 6/6] removing ; from end of package subroutine calls --- snippets/perl.snippets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 2670e49..6fc7346 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -134,19 +134,19 @@ snippet begin # call package function with some parameter snippet pkgmv - __PACKAGE__->${1:package_method}(${2:var}); + __PACKAGE__->${1:package_method}(${2:var}) # call package function without a parameter snippet pkgm - __PACKAGE__->${1:package_method}(); + __PACKAGE__->${1:package_method}() # call package "get_" function without a parameter snippet pkget - __PACKAGE__->get_${1:package_method}(); + __PACKAGE__->get_${1:package_method}() # call package function with a parameter snippet pkgetv - __PACKAGE__->get_${1:package_method}(${2:var}); + __PACKAGE__->get_${1:package_method}(${2:var}) # complex regex snippet qrx