line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Array::Merge::Unique; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
136918
|
use 5.006; |
|
2
|
|
|
|
|
17
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
74
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1022
|
use Import::Export; |
|
2
|
|
|
|
|
35913
|
|
|
2
|
|
|
|
|
12
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
103
|
use base qw/Import::Export/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
455
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %EX = ( |
13
|
|
|
|
|
|
|
unique_array => [qw/all/] |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub unique_array { |
17
|
3
|
|
|
3
|
1
|
110
|
my (@dataset, %u); |
18
|
|
|
|
|
|
|
@dataset = grep { |
19
|
3
|
100
|
|
|
|
10
|
my $k = ref $_ ? $_ + 0 : $_; |
|
18
|
|
|
|
|
34
|
|
20
|
18
|
100
|
|
|
|
48
|
!$u{$k} && do { $u{$k} = 1; $_ } |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
26
|
|
21
|
|
|
|
|
|
|
} _aoaoaoa(@_); |
22
|
3
|
100
|
|
|
|
20
|
return wantarray ? @dataset : \@dataset; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _aoaoaoa { |
26
|
9
|
100
|
|
9
|
|
15
|
return map { ref $_ eq 'ARRAY' ? _aoaoaoa(@{ $_ }) : $_ } @_; |
|
24
|
|
|
|
|
52
|
|
|
6
|
|
|
|
|
17
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Array::Merge::Unique - Merge those arrays uniquely |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 VERSION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Version 1.00 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Quick summary of what the module does. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use Array::Merge::Unique qw/unique_array/; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $arrayref = unique_array([qw/one two three/], qw/one two/); |
48
|
|
|
|
|
|
|
my @array = unique_array([qw/one two three/], qw/one two/); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 EXPORT |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 unique_array |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This module exports a single method unique_array that accepts multiple Arrays and |
55
|
|
|
|
|
|
|
merges them uniquely by value or reference. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $ref = { a => "b" }; |
58
|
|
|
|
|
|
|
my $arrayref = unique_array([qw/one two three/, $ref], qw/one two/, $ref); # qw/one two three/, $ref |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Robert Acock, C<< >> |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 BUGS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
67
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
68
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SUPPORT |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
perldoc Array::Merge::Unique |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
You can also look for information at: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=over 4 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
L |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * CPAN Ratings |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * Search CPAN |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright 2017->2020 Robert Acock. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
105
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
106
|
|
|
|
|
|
|
copy of the full license at: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
111
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
112
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
113
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
116
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
117
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
120
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
123
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
124
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
125
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
126
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
127
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
128
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
129
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
132
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
133
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
134
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
135
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
136
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
137
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
138
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; # End of Array::Merge::Unique |