| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Parse::VarName; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2016-06-14'; # DATE |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
382
|
use 5.010001; |
|
|
1
|
|
|
|
|
3
|
|
|
7
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
14
|
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
3
|
use Exporter qw(import); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
227
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(split_varname_words); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %SPEC; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$SPEC{':package'} = { |
|
16
|
|
|
|
|
|
|
v => 1.1, |
|
17
|
|
|
|
|
|
|
summary => 'Routines to parse variable name', |
|
18
|
|
|
|
|
|
|
}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# cannot be put inside sub, warning "Variable %s will not stay shared" |
|
21
|
|
|
|
|
|
|
my @res; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$SPEC{split_varname_words} = { |
|
24
|
|
|
|
|
|
|
v => 1.1, |
|
25
|
|
|
|
|
|
|
summary => 'Split words found in variable name', |
|
26
|
|
|
|
|
|
|
description => <<'_', |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Try to split words found in a variable name, e.g. mTime -> [m, Time], foo1Bar -> |
|
29
|
|
|
|
|
|
|
[foo, 1, Bar], Foo::barBaz::Qux2 -> [Foo, bar, Baz, Qux, 2]. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
_ |
|
32
|
|
|
|
|
|
|
args => { |
|
33
|
|
|
|
|
|
|
varname => { |
|
34
|
|
|
|
|
|
|
schema => 'str*', |
|
35
|
|
|
|
|
|
|
req => 1, |
|
36
|
|
|
|
|
|
|
pos => 1, |
|
37
|
|
|
|
|
|
|
}, |
|
38
|
|
|
|
|
|
|
include_sep => { |
|
39
|
|
|
|
|
|
|
summary => 'Whether to include non-alphanum separator in result', |
|
40
|
|
|
|
|
|
|
description => <<'_', |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
For example, under include_sep=true, Foo::barBaz::Qux2 -> [Foo, ::, bar, Baz, |
|
43
|
|
|
|
|
|
|
::, Qux, 2]. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
_ |
|
46
|
|
|
|
|
|
|
schema => [bool => {default=>0}], |
|
47
|
|
|
|
|
|
|
}, |
|
48
|
|
|
|
|
|
|
}, |
|
49
|
|
|
|
|
|
|
result_naked => 1, |
|
50
|
|
|
|
|
|
|
}; |
|
51
|
|
|
|
|
|
|
sub split_varname_words { |
|
52
|
20
|
|
|
20
|
1
|
8663
|
my %args = @_; |
|
53
|
20
|
50
|
|
|
|
49
|
my $v = $args{varname} or return [400, "Please specify varname"]; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#no warnings; |
|
56
|
20
|
|
|
|
|
30
|
@res = (); |
|
57
|
20
|
50
|
|
|
|
79
|
$v =~ m!\A(?: |
|
58
|
|
|
|
|
|
|
( |
|
59
|
|
|
|
|
|
|
[A-Z][A-Z]+ | |
|
60
|
|
|
|
|
|
|
[A-Z][a-z]+ | |
|
61
|
|
|
|
|
|
|
[a-z]+ | |
|
62
|
|
|
|
|
|
|
[0-9]+ | |
|
63
|
|
|
|
|
|
|
[^A-Za-z0-9]+ |
|
64
|
|
|
|
|
|
|
) |
|
65
|
51
|
|
|
|
|
175
|
(?{ push @res, $1 }) |
|
66
|
|
|
|
|
|
|
)+\z!sxg |
|
67
|
|
|
|
|
|
|
or return []; |
|
68
|
20
|
100
|
|
|
|
38
|
unless ($args{include_sep}) { |
|
69
|
16
|
|
|
|
|
17
|
@res = grep {/[A-Za-z0-9]/} @res; |
|
|
37
|
|
|
|
|
93
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
20
|
|
|
|
|
49
|
\@res; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
|
76
|
|
|
|
|
|
|
# ABSTRACT: Routines to parse variable name |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |