line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perinci::Easy; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-09-03'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.29'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
19039
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
160
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(defsub); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %SPEC; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$SPEC{':package'} = { |
16
|
|
|
|
|
|
|
v => 1.1, |
17
|
|
|
|
|
|
|
summary => 'Some easy shortcuts for Perinci', |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$SPEC{defsub} = { |
21
|
|
|
|
|
|
|
v => 1.1, |
22
|
|
|
|
|
|
|
summary => 'Define a subroutine', |
23
|
|
|
|
|
|
|
description => <<'_', |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This is just a shortcut to define subroutine and meta together so instead of: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our %SPEC; |
28
|
|
|
|
|
|
|
$SPEC{foo} = { |
29
|
|
|
|
|
|
|
v => 1.1, |
30
|
|
|
|
|
|
|
summary => 'Blah ...', |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
sub foo { |
33
|
|
|
|
|
|
|
... |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
you write: |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
defsub name=>'foo', summary=>'Blah ...', |
39
|
|
|
|
|
|
|
code=>sub { |
40
|
|
|
|
|
|
|
... |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
_ |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
sub defsub(%) { |
46
|
1
|
|
|
1
|
1
|
22
|
my %args = @_; |
47
|
1
|
50
|
|
|
|
6
|
my $name = $args{name} or die "Please specify subroutine's name"; |
48
|
1
|
50
|
|
|
|
4
|
my $code = $args{code} or die "Please specify subroutine's code"; |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
6
|
my $spec = {%args}; |
51
|
1
|
|
|
|
|
4
|
delete $spec->{code}; |
52
|
1
|
|
50
|
|
|
10
|
$spec->{v} //= 1.1; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
125
|
|
55
|
1
|
|
|
|
|
5
|
my ($callpkg, undef, undef) = caller; |
56
|
1
|
|
|
|
|
3
|
${$callpkg . '::SPEC'}{$name} = $spec; |
|
1
|
|
|
|
|
7
|
|
57
|
1
|
|
|
|
|
3
|
*{$callpkg . "::$name"} = $code; |
|
1
|
|
|
|
|
8
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
0
|
0
|
|
sub defvar { |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
0
|
0
|
|
sub defpkg { |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
0
|
0
|
|
sub defclass { |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
# ABSTRACT: Some easy shortcuts for Perinci |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |