]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/snippets/perl.snippets
Update vim plugins
[rbdr/dotfiles] / vim / snippets / perl.snippets
CommitLineData
0d23b6e5
BB
1# #!/usr/bin/perl
2snippet #!
3 #!/usr/bin/perl
4
5# Hash Pointer
6snippet .
7 =>
8# Function
9snippet sub
10 sub ${1:function_name} {
11 ${2:#body ...}
12 }
13# Conditional
14snippet if
15 if (${1}) {
16 ${2:# body...}
17 }
18# Conditional if..else
19snippet ife
20 if (${1}) {
21 ${2:# body...}
22 }
23 else {
24 ${3:# else...}
25 }
26# Conditional if..elsif..else
27snippet ifee
28 if (${1}) {
29 ${2:# body...}
30 }
31 elsif (${3}) {
32 ${4:# elsif...}
33 }
34 else {
35 ${5:# else...}
36 }
37# Conditional One-line
38snippet xif
39 ${1:expression} if ${2:condition};${3}
40# Unless conditional
41snippet unless
42 unless (${1}) {
43 ${2:# body...}
44 }
45# Unless conditional One-line
46snippet xunless
47 ${1:expression} unless ${2:condition};${3}
48# Try/Except
49snippet eval
50 eval {
51 ${1:# do something risky...}
52 };
53 if ($@) {
54 ${2:# handle failure...}
55 }
56# While Loop
57snippet wh
58 while (${1}) {
59 ${2:# body...}
60 }
61# While Loop One-line
62snippet xwh
63 ${1:expression} while ${2:condition};${3}
64# C-style For Loop
65snippet cfor
66 for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
67 ${4:# body...}
68 }
69# For loop one-line
70snippet xfor
71 ${1:expression} for @${2:array};${3}
72# Foreach Loop
73snippet for
74 foreach my $${1:x} (@${2:array}) {
75 ${3:# body...}
76 }
77# Foreach Loop One-line
78snippet fore
79 ${1:expression} foreach @${2:array};${3}
80# Package
81snippet cl
82 package ${1:ClassName};
83
84 use base qw(${2:ParentClass});
85
86 sub new {
87 my $class = shift;
88 $class = ref $class if ref $class;
89 my $self = bless {}, $class;
90 $self;
91 }
92
93 1;${3}
94# Read File
95snippet slurp
96 my $${1:var};
97 { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }${3}