shortcuts for various Perl constructs
This commit is contained in:
parent
eb3dc27d75
commit
bfc34d3713
58
snippets/perl-basic.snippets
Normal file
58
snippets/perl-basic.snippets
Normal file
@ -0,0 +1,58 @@
|
||||
# #!/usr/bin/perl
|
||||
|
||||
# strict warnings
|
||||
snippet strwar
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
||||
# standard versioning with perlcritic bypass
|
||||
snippet vers
|
||||
## no critic
|
||||
our $VERSION = '${1:version}';
|
||||
eval $VERSION;
|
||||
## use critic
|
||||
|
||||
|
||||
|
||||
# Anonymous subroutine
|
||||
snippet asub
|
||||
sub {
|
||||
${1:# body }
|
||||
}
|
||||
|
||||
|
||||
# Begin block
|
||||
snippet begin
|
||||
BEGIN { #{{{
|
||||
${1:# begin body}
|
||||
} #}}}
|
||||
|
||||
# call package function
|
||||
snippet pkgm
|
||||
__PACKAGE__->${1:package_method}(${2:var});
|
||||
|
||||
# complex regex
|
||||
snippet qrx
|
||||
qr/
|
||||
${1:regex}
|
||||
/xms
|
||||
|
||||
#simpler regex
|
||||
snippet qr/
|
||||
qr/${1:regex}/x
|
||||
|
||||
#switch
|
||||
snippet switch
|
||||
switch ($${1:var}) { #{{{
|
||||
${2:# cases}
|
||||
} #}}}
|
||||
|
||||
# switch case
|
||||
snippet case
|
||||
case ${1:case} {
|
||||
${2:# body}
|
||||
}
|
||||
|
||||
|
||||
|
37
snippets/perl-moosesnippets.snippets
Normal file
37
snippets/perl-moosesnippets.snippets
Normal file
@ -0,0 +1,37 @@
|
||||
# #!/usr/bin/perl
|
||||
|
||||
# Moose package
|
||||
snippet moosecl
|
||||
package ${1:ClassName};
|
||||
|
||||
use Moose;
|
||||
#extends ${2:# ParentClass};
|
||||
|
||||
${6:# body of class}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
$1 - ${3:ShortDesc}
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
${4:# synopsis...}
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
${5:# longer description...}
|
||||
|
||||
|
||||
# has
|
||||
snippet has
|
||||
has ${1:attribute} => ( #{{{
|
||||
is => '${2:ro|rw}',
|
||||
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
|
||||
default => ${4:defaultvalue}
|
||||
,${5:# other attributes}
|
||||
); #}}}
|
||||
|
||||
|
29
snippets/perl-test.snippets
Normal file
29
snippets/perl-test.snippets
Normal file
@ -0,0 +1,29 @@
|
||||
# #!/usr/bin/perl
|
||||
|
||||
# use test classes
|
||||
snippet tuse
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Test::Exception;
|
||||
|
||||
# local test lib
|
||||
snippet tlib
|
||||
use lib qw{ ./t/lib };
|
||||
|
||||
#test methods
|
||||
snippet tmeths
|
||||
$ENV{TEST_METHOD} = '${1:regex}';
|
||||
|
||||
# runtestclass
|
||||
snippet trunner
|
||||
use ${1:test_class};
|
||||
$1->runtests();
|
||||
|
||||
#testclass
|
||||
snippet tsub
|
||||
sub t${1:number}_${2:test_case} Test:(${3:num_of_tests}) { #{{{
|
||||
${4:# body}
|
||||
|
||||
} #}}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user