line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Util::Uniq; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
71557
|
use strict; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
670
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
9
|
|
|
|
|
|
|
our $DATE = '2023-06-21'; # DATE |
10
|
|
|
|
|
|
|
our $DIST = 'List-Util-Uniq'; # DIST |
11
|
|
|
|
|
|
|
our $VERSION = '0.006'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
14
|
|
|
|
|
|
|
uniq |
15
|
|
|
|
|
|
|
uniqint |
16
|
|
|
|
|
|
|
uniqnum |
17
|
|
|
|
|
|
|
uniqstr |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
uniq_adj |
20
|
|
|
|
|
|
|
uniq_adj_ci |
21
|
|
|
|
|
|
|
uniq_ci |
22
|
|
|
|
|
|
|
is_uniq |
23
|
|
|
|
|
|
|
is_uniq_ci |
24
|
|
|
|
|
|
|
is_monovalued |
25
|
|
|
|
|
|
|
is_monovalued_ci |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
dupe |
28
|
|
|
|
|
|
|
dupeint |
29
|
|
|
|
|
|
|
dupenum |
30
|
|
|
|
|
|
|
dupestr |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
dupe_ci |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub uniq_adj { |
36
|
2
|
|
|
2
|
1
|
4145
|
my @res; |
37
|
|
|
|
|
|
|
|
38
|
2
|
50
|
|
|
|
8
|
return () unless @_; |
39
|
2
|
|
|
|
|
4
|
my $last = shift; |
40
|
2
|
|
|
|
|
4
|
push @res, $last; |
41
|
2
|
|
|
|
|
6
|
for (@_) { |
42
|
12
|
0
|
33
|
|
|
21
|
next if !defined($_) && !defined($last); |
43
|
|
|
|
|
|
|
# XXX $_ becomes stringified |
44
|
12
|
100
|
33
|
|
|
51
|
next if defined($_) && defined($last) && $_ eq $last; |
|
|
|
66
|
|
|
|
|
45
|
10
|
|
|
|
|
16
|
push @res, $_; |
46
|
10
|
|
|
|
|
14
|
$last = $_; |
47
|
|
|
|
|
|
|
} |
48
|
2
|
|
|
|
|
28
|
@res; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub uniq_adj_ci { |
52
|
1
|
|
|
1
|
1
|
3
|
my @res; |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
|
|
|
4
|
return () unless @_; |
55
|
1
|
|
|
|
|
4
|
my $last = shift; |
56
|
1
|
|
|
|
|
5
|
push @res, $last; |
57
|
1
|
|
|
|
|
5
|
for (@_) { |
58
|
6
|
0
|
33
|
|
|
24
|
next if !defined($_) && !defined($last); |
59
|
|
|
|
|
|
|
# XXX $_ becomes stringified |
60
|
6
|
100
|
33
|
|
|
31
|
next if defined($_) && defined($last) && lc($_) eq lc($last); |
|
|
|
66
|
|
|
|
|
61
|
4
|
|
|
|
|
7
|
push @res, $_; |
62
|
4
|
|
|
|
|
6
|
$last = $_; |
63
|
|
|
|
|
|
|
} |
64
|
1
|
|
|
|
|
7
|
@res; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub uniq_ci { |
68
|
2
|
|
|
2
|
1
|
2438
|
my @res; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my %mem; |
71
|
2
|
|
|
|
|
0
|
my $undef_added; |
72
|
2
|
|
|
|
|
6
|
for (@_) { |
73
|
13
|
100
|
|
|
|
22
|
if (defined) { |
74
|
11
|
100
|
|
|
|
31
|
push @res, $_ unless $mem{lc $_}++; |
75
|
|
|
|
|
|
|
} else { |
76
|
2
|
100
|
|
|
|
5
|
push @res, $_ unless $undef_added++; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
2
|
|
|
|
|
16
|
@res; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub is_uniq { |
83
|
5
|
|
|
5
|
1
|
2428
|
my %vals; |
84
|
5
|
|
|
|
|
15
|
for (@_) { |
85
|
7
|
100
|
|
|
|
29
|
return 0 if $vals{$_}++; |
86
|
|
|
|
|
|
|
} |
87
|
4
|
|
|
|
|
18
|
1; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub is_uniq_ci { |
91
|
5
|
|
|
5
|
1
|
2200
|
my %vals; |
92
|
5
|
|
|
|
|
12
|
for (@_) { |
93
|
7
|
100
|
|
|
|
33
|
return 0 if $vals{lc $_}++; |
94
|
|
|
|
|
|
|
} |
95
|
3
|
|
|
|
|
11
|
1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub is_monovalued { |
99
|
5
|
|
|
5
|
1
|
2202
|
my %vals; |
100
|
5
|
|
|
|
|
14
|
for (@_) { |
101
|
7
|
|
|
|
|
13
|
$vals{$_} = 1; |
102
|
7
|
100
|
|
|
|
32
|
return 0 if keys(%vals) > 1; |
103
|
|
|
|
|
|
|
} |
104
|
3
|
|
|
|
|
15
|
1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub is_monovalued_ci { |
108
|
5
|
|
|
5
|
1
|
2255
|
my %vals; |
109
|
5
|
|
|
|
|
13
|
for (@_) { |
110
|
7
|
|
|
|
|
19
|
$vals{lc $_} = 1; |
111
|
7
|
100
|
|
|
|
23
|
return 0 if keys(%vals) > 1; |
112
|
|
|
|
|
|
|
} |
113
|
4
|
|
|
|
|
16
|
1; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub uniqint { |
117
|
1
|
|
|
1
|
0
|
3
|
my (@uniqs, %vals); |
118
|
1
|
|
|
|
|
5
|
for (@_) { |
119
|
1
|
|
|
1
|
|
8
|
no warnings 'numeric'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
120
|
4
|
100
|
|
|
|
11
|
++$vals{int $_} == 1 and push @uniqs, $_; |
121
|
|
|
|
|
|
|
} |
122
|
1
|
|
|
|
|
10
|
@uniqs; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub uniqnum { |
126
|
1
|
|
|
1
|
0
|
2
|
my (@uniqs, %vals); |
127
|
1
|
|
|
|
|
3
|
for (@_) { |
128
|
1
|
|
|
1
|
|
7
|
no warnings 'numeric'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
174
|
|
129
|
4
|
100
|
|
|
|
13
|
++$vals{$_+0} == 1 and push @uniqs, $_; |
130
|
|
|
|
|
|
|
} |
131
|
1
|
|
|
|
|
5
|
@uniqs; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub uniqstr { |
135
|
2
|
|
|
2
|
0
|
5
|
my (@uniqs, %vals); |
136
|
2
|
|
|
|
|
5
|
for (@_) { |
137
|
7
|
100
|
|
|
|
20
|
++$vals{$_} == 1 and push @uniqs, $_; |
138
|
|
|
|
|
|
|
} |
139
|
2
|
|
|
|
|
11
|
@uniqs; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
1
|
0
|
5
|
sub uniq { goto \&uniqstr } |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub dupeint { |
145
|
6
|
|
|
6
|
1
|
2493
|
my (@dupes, %vals); |
146
|
6
|
|
|
|
|
14
|
for (@_) { |
147
|
1
|
|
|
1
|
|
7
|
no warnings 'numeric'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
114
|
|
148
|
20
|
100
|
|
|
|
100
|
++$vals{int $_} > 1 and push @dupes, $_; |
149
|
|
|
|
|
|
|
} |
150
|
6
|
|
|
|
|
61
|
@dupes; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub dupenum { |
154
|
5
|
|
|
5
|
1
|
2419
|
my (@dupes, %vals); |
155
|
5
|
|
|
|
|
11
|
for (@_) { |
156
|
1
|
|
|
1
|
|
7
|
no warnings 'numeric'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
243
|
|
157
|
18
|
100
|
|
|
|
57
|
++$vals{$_+0} > 1 and push @dupes, $_; |
158
|
|
|
|
|
|
|
} |
159
|
5
|
|
|
|
|
37
|
@dupes; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub dupestr { |
163
|
10
|
|
|
10
|
1
|
2527
|
my (@dupes, %vals); |
164
|
10
|
|
|
|
|
21
|
for (@_) { |
165
|
46
|
100
|
|
|
|
126
|
++$vals{$_} > 1 and push @dupes, $_; |
166
|
|
|
|
|
|
|
} |
167
|
10
|
|
|
|
|
57
|
@dupes; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
5
|
|
|
5
|
1
|
2233
|
sub dupe { goto \&dupestr } |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub dupe_ci { |
173
|
2
|
|
|
2
|
1
|
2496
|
my @res; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my %mem; |
176
|
2
|
|
|
|
|
0
|
my $undef_added; |
177
|
2
|
|
|
|
|
8
|
for (@_) { |
178
|
13
|
100
|
|
|
|
23
|
if (defined) { |
179
|
11
|
100
|
|
|
|
48
|
push @res, $_ if $mem{lc $_}++; |
180
|
|
|
|
|
|
|
} else { |
181
|
2
|
100
|
|
|
|
9
|
push @res, $_ if $undef_added++; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
2
|
|
|
|
|
18
|
@res; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; |
188
|
|
|
|
|
|
|
# ABSTRACT: List utilities related to finding unique items |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
__END__ |