line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tangerine::Utils; |
2
|
|
|
|
|
|
|
$Tangerine::Utils::VERSION = '0.19'; |
3
|
15
|
|
|
15
|
|
67
|
use strict; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
463
|
|
4
|
15
|
|
|
15
|
|
70
|
use warnings; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
446
|
|
5
|
15
|
|
|
15
|
|
69
|
use Exporter 'import'; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
560
|
|
6
|
15
|
|
|
15
|
|
69
|
use List::MoreUtils qw(apply); |
|
15
|
|
|
|
|
20
|
|
|
15
|
|
|
|
|
99
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(accessor addoccurence stripquotelike); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub accessor { |
10
|
|
|
|
|
|
|
# TODO: This needs checks |
11
|
2822
|
100
|
|
2822
|
1
|
14094
|
$_[1]->{$_[0]} = $_[2] ? $_[2] : $_[1]->{$_[0]} |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub stripquotelike { |
15
|
|
|
|
|
|
|
my @filtered = map { |
16
|
128
|
100
|
|
|
|
754
|
if (/^('|").*$/o) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
17
|
62
|
|
|
|
|
275
|
substr $_, 1, -1 |
18
|
|
|
|
|
|
|
} elsif (/^(\(|\[|\{).*$/so) { |
19
|
14
|
|
|
|
|
841
|
stripquotelike(split /,|=>/so, substr $_, 1, -1) |
20
|
|
|
|
|
|
|
} elsif (/^qq?\s*[^\w](.*)[^\w]$/so) { |
21
|
5
|
|
|
|
|
39
|
$1 |
22
|
|
|
|
|
|
|
} elsif (/^qw\s*[^\w](.*)[^\w]$/so) { |
23
|
21
|
|
|
|
|
335
|
grep { $_ } split /\s+/so, $1 |
|
47
|
|
|
|
|
122
|
|
24
|
|
|
|
|
|
|
} else { |
25
|
26
|
|
|
|
|
196
|
$_ |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} grep { |
28
|
195
|
100
|
|
|
|
989
|
1 if !/^(,|=>|;|)$/so |
29
|
|
|
|
|
|
|
} apply { |
30
|
195
|
|
|
195
|
|
367
|
s/^\s+|\s+$//sgo; |
31
|
195
|
|
|
|
|
1197
|
$_ |
32
|
86
|
|
|
86
|
1
|
925
|
} @_; |
33
|
86
|
100
|
|
|
|
534
|
return wantarray ? @filtered : $filtered[0]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub addoccurence { |
37
|
174
|
|
|
174
|
1
|
240
|
my ($a, $b) = @_; |
38
|
174
|
|
|
|
|
305
|
for my $k (keys %$b) { |
39
|
152
|
100
|
|
|
|
229
|
if (exists $$a{$k}) { |
40
|
39
|
|
|
|
|
44
|
$a->{$k} = [ @{$a->{$k}}, $b->{$k} ]; |
|
39
|
|
|
|
|
114
|
|
41
|
|
|
|
|
|
|
} else { |
42
|
113
|
|
|
|
|
287
|
$a->{$k} = [ $b->{$k} ]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
174
|
|
|
|
|
458
|
return $a; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |