line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tangerine::Utils; |
2
|
|
|
|
|
|
|
$Tangerine::Utils::VERSION = '0.23'; |
3
|
16
|
|
|
16
|
|
349
|
use 5.010; |
|
16
|
|
|
|
|
136
|
|
4
|
16
|
|
|
16
|
|
52
|
use strict; |
|
16
|
|
|
|
|
14
|
|
|
16
|
|
|
|
|
275
|
|
5
|
16
|
|
|
16
|
|
40
|
use warnings; |
|
16
|
|
|
|
|
16
|
|
|
16
|
|
|
|
|
329
|
|
6
|
16
|
|
|
16
|
|
5620
|
use version 0.77; |
|
16
|
|
|
|
|
20279
|
|
|
16
|
|
|
|
|
70
|
|
7
|
16
|
|
|
16
|
|
841
|
use Exporter 'import'; |
|
16
|
|
|
|
|
19
|
|
|
16
|
|
|
|
|
7469
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(accessor addoccurence any none stripquotelike $vre); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $vre = defined($version::LAX) ? |
11
|
|
|
|
|
|
|
qr/^($version::LAX)$/o : |
12
|
|
|
|
|
|
|
(defined($version::regex::LAX) ? |
13
|
|
|
|
|
|
|
qr/^($version::regex::LAX)$/o : |
14
|
|
|
|
|
|
|
qr/^(v?[0-9]+(?:\.[0-9]+)*(?:_[0-9]+)?)$/o ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $HAVE_LIST_UTIL_133 = eval { require List::Util; List::Util->VERSION(1.33) }; |
17
|
|
|
|
|
|
|
unless ($HAVE_LIST_UTIL_133) { require List::MoreUtils } |
18
|
|
|
|
|
|
|
*any = $HAVE_LIST_UTIL_133 ? \&List::Util::any : \&List::MoreUtils::any; |
19
|
|
|
|
|
|
|
*none = $HAVE_LIST_UTIL_133 ? \&List::Util::none : \&List::MoreUtils::none; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub accessor { |
22
|
|
|
|
|
|
|
# TODO: This needs checks |
23
|
3091
|
100
|
|
3091
|
1
|
11752
|
$_[1]->{$_[0]} = $_[2] ? $_[2] : $_[1]->{$_[0]} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub stripquotelike { |
27
|
|
|
|
|
|
|
my @filtered = map { |
28
|
159
|
100
|
|
|
|
689
|
if (/^(?:'|").*$/o) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
29
|
76
|
|
|
|
|
261
|
substr $_, 1, -1 |
30
|
|
|
|
|
|
|
} elsif (/^(?:\(|\[|\{).*$/so) { |
31
|
19
|
|
|
|
|
855
|
stripquotelike(split /,|=>/so, substr $_, 1, -1) |
32
|
|
|
|
|
|
|
} elsif (/^qq?\s*[^\w](.*)[^\w]$/so) { |
33
|
5
|
|
|
|
|
31
|
$1 |
34
|
|
|
|
|
|
|
} elsif (/^qw\s*[^\w](.*)[^\w]$/so) { |
35
|
23
|
|
|
|
|
273
|
grep { $_ } split /\s+/so, $1 |
|
52
|
|
|
|
|
101
|
|
36
|
|
|
|
|
|
|
} else { |
37
|
36
|
|
|
|
|
201
|
$_ |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} grep { |
40
|
244
|
100
|
|
|
|
986
|
1 if !/^(?:,|=>|;|)$/so |
41
|
|
|
|
|
|
|
} map { |
42
|
101
|
|
|
101
|
1
|
629
|
(my $trim = $_) =~ s/^\s+|\s+$//sgo; $trim |
|
244
|
|
|
|
|
385
|
|
|
244
|
|
|
|
|
1168
|
|
43
|
|
|
|
|
|
|
} @_; |
44
|
101
|
100
|
|
|
|
401
|
return wantarray ? @filtered : $filtered[0]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub addoccurence { |
48
|
190
|
|
|
190
|
1
|
182
|
my ($a, $b) = @_; |
49
|
190
|
|
|
|
|
259
|
for my $k (keys %$b) { |
50
|
168
|
100
|
|
|
|
209
|
if (exists $$a{$k}) { |
51
|
43
|
|
|
|
|
43
|
$a->{$k} = [ @{$a->{$k}}, $b->{$k} ]; |
|
43
|
|
|
|
|
97
|
|
52
|
|
|
|
|
|
|
} else { |
53
|
125
|
|
|
|
|
217
|
$a->{$k} = [ $b->{$k} ]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
190
|
|
|
|
|
339
|
return $a; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |