File Coverage

blib/lib/Hash/Util/Exists/Tiny.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 14 14 100.0
pod 10 10 100.0
total 49 49 100.0


line stmt bran cond sub pod time code
1             package Hash::Util::Exists::Tiny;
2              
3 2     2   188469 use 5.010_001;
  2         7  
4 2     2   11 use strict;
  2         3  
  2         81  
5 2     2   10 use warnings FATAL => 'all';
  2         3  
  2         118  
6              
7 2     2   10 use Exporter 'import';
  2         6  
  2         932  
8              
9             our $VERSION = '1.03';
10              
11              
12             our @EXPORT_OK = qw(exists_one_of
13             list_exists list_exists_unique
14             num_exists num_exists_unique
15             defined_one_of
16             list_defined list_defined_unique
17             num_defined num_defined_unique);
18             our %EXPORT_TAGS = (all => \@EXPORT_OK);
19              
20              
21              
22             sub exists_one_of {
23 7     7 1 230911 return !!grep(exists($_[0]->{$_}), @_);
24             }
25              
26              
27             sub list_exists {
28 6     6 1 1107 return grep(exists($_[0]->{$_}), @_);
29             }
30              
31              
32             sub list_exists_unique {
33 6     6 1 1386 my %seen;
34 6         86 return grep(exists($_[0]->{$_}), grep(!$seen{$_}++, @_));
35             }
36              
37              
38             sub num_exists {
39 6     6 1 1391 return scalar grep(exists($_[0]->{$_}), @_);
40             }
41              
42              
43             sub num_exists_unique {
44 6     6 1 894 my %seen;
45 6         78 return scalar grep(exists($_[0]->{$_}), grep(!$seen{$_}++, @_));
46             }
47              
48              
49             sub defined_one_of {
50 7     7 1 907 return !!grep(defined($_[0]->{$_}), @_);
51             }
52              
53              
54             sub list_defined {
55 6     6 1 548 return grep(defined($_[0]->{$_}), @_);
56             }
57              
58              
59             sub list_defined_unique {
60 6     6 1 757 my %seen;
61 6         74 return grep(defined($_[0]->{$_}), grep(!$seen{$_}++, @_));
62             }
63              
64              
65             sub num_defined {
66 6     6 1 2024 return scalar grep(defined($_[0]->{$_}), @_);
67             }
68              
69              
70             sub num_defined_unique {
71 6     6 1 1494 my %seen;
72 6         58 return scalar grep(defined($_[0]->{$_}), grep(!$seen{$_}++, @_));
73             }
74              
75              
76              
77             1;
78              
79             __END__