File Coverage

blib/lib/Array/Merge/Unique.pm
Criterion Covered Total %
statement 24 24 100.0
branch 8 8 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 40 40 100.0


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