Cleaned perl snippets up
This commit is contained in:
parent
954e579d7b
commit
9c3456e3c5
@ -1,3 +1,6 @@
|
|||||||
|
###########################################################################
|
||||||
|
# TextMate Snippets #
|
||||||
|
###########################################################################
|
||||||
snippet ife "Conditional if..else (ife)"
|
snippet ife "Conditional if..else (ife)"
|
||||||
if ($1) {
|
if ($1) {
|
||||||
${2:# body...}
|
${2:# body...}
|
||||||
@ -59,13 +62,11 @@ endsnippet
|
|||||||
snippet class "class"
|
snippet class "class"
|
||||||
package ${1:ClassName};
|
package ${1:ClassName};
|
||||||
|
|
||||||
${2:use base qw(${3:ParentClass});
|
${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new {
|
||||||
|
my $class = shift;
|
||||||
}sub new {
|
$class = ref $class if ref $class;
|
||||||
my \$class = shift;
|
my $self = bless {}, $class;
|
||||||
\$class = ref \$class if ref \$class;
|
$self;
|
||||||
my \$self = bless {}, \$class;
|
|
||||||
\$self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -76,21 +77,21 @@ snippet eval "eval"
|
|||||||
eval {
|
eval {
|
||||||
${1:# do something risky...}
|
${1:# do something risky...}
|
||||||
};
|
};
|
||||||
if (\$@) {
|
if ($@) {
|
||||||
${2:# handle failure...}
|
${2:# handle failure...}
|
||||||
}
|
}
|
||||||
|
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet for "for"
|
snippet for "for"
|
||||||
for (my \$${1:var} = 0; \$$1 < ${2:expression}; \$$1++) {
|
for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) {
|
||||||
${3:# body...}
|
${3:# body...}
|
||||||
}
|
}
|
||||||
|
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet fore "foreach"
|
snippet fore "foreach"
|
||||||
foreach ${1:my \$${2:x}} (@${3:array}) {
|
foreach ${1:my $${2:x}} (@${3:array}) {
|
||||||
${4:# body...}
|
${4:# body...}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +105,8 @@ if ($1) {
|
|||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet slurp "slurp"
|
snippet slurp "slurp"
|
||||||
my \$${1:var};
|
my $${1:var};
|
||||||
{ local \$/ = undef; local *FILE; open FILE, "<${2:file}"; \$$1 = <FILE>; close FILE }
|
{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }
|
||||||
|
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
Loading…
Reference in New Issue
Block a user