File Coverage

blib/lib/Rex/Helper/Array.pm
Criterion Covered Total %
statement 11 21 52.3
branch 0 4 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 15 36 41.6


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Helper::Array;
6              
7 102     102   1309 use v5.12.5;
  102         336  
8 102     102   552 use warnings;
  102         206  
  102         5254  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12             require Exporter;
13 102     102   1146 use base qw(Exporter);
  102         236  
  102         17483  
14 102     102   759 use vars qw(@EXPORT);
  102         216  
  102         21625  
15              
16             @EXPORT = qw(array_uniq in_array);
17              
18             sub array_uniq {
19 0     0 0   my (@array) = @_;
20              
21 0           my %all = ();
22 0           @all{@array} = 1;
23 0           return keys %all;
24             }
25              
26             sub in_array {
27 0     0 0   my ( $needle, @haystack ) = @_;
28              
29             my ($ret) = grep {
30 0 0 0       if ( ref $needle eq "RegExp" && $_ =~ $needle ) {
  0 0          
31 0           return $_;
32             }
33             elsif ( $_ eq $needle ) {
34 0           return $_;
35             }
36             } @haystack;
37              
38 0           return $ret;
39             }
40              
41             1;