| 1 | package Hash::Util::Exists::Tiny; | ||
| 2 | |||
| 3 | 2 | ▶ | use 5.010_001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 2 | our $VERSION = '1.04'; | |
| 10 | |||
| 11 | |||
| 12 | 2 | 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 | 2 | our %EXPORT_TAGS = (all => \@EXPORT_OK); | |
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | 7 | ▶ | sub exists_one_of { |
|
Subroutine
exists_one_of: called CC=1 SCAR=0.0
Pod
documented
| |||
| 23 | 7 | return !!grep(exists($_[0]->{$_}), @_); | |
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | 6 | ▶ | sub list_exists { |
|
Subroutine
list_exists: called CC=1 SCAR=0.0
Pod
documented
| |||
| 28 | 6 | return grep(exists($_[0]->{$_}), @_); | |
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | 6 | ▶ | sub list_exists_unique { |
|
Subroutine
list_exists_unique: called CC=1 SCAR=0.0
Pod
documented
| |||
| 33 | 6 | my %seen; | |
| 34 | 6 | return grep(exists($_[0]->{$_}), grep(!$seen{$_}++, @_)); | |
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | 6 | ▶ | sub num_exists { |
|
Subroutine
num_exists: called CC=1 SCAR=0.0
Pod
documented
| |||
| 39 | 6 | return scalar grep(exists($_[0]->{$_}), @_); | |
| 40 | } | ||
| 41 | |||
| 42 | |||
| 43 | 6 | ▶ | sub num_exists_unique { |
|
Subroutine
num_exists_unique: called CC=1 SCAR=0.0
Pod
documented
| |||
| 44 | 6 | my %seen; | |
| 45 | 6 | return scalar grep(exists($_[0]->{$_}), grep(!$seen{$_}++, @_)); | |
| 46 | } | ||
| 47 | |||
| 48 | |||
| 49 | 7 | ▶ | sub defined_one_of { |
|
Subroutine
defined_one_of: called CC=1 SCAR=0.0
Pod
documented
| |||
| 50 | 7 | return !!grep(defined($_[0]->{$_}), @_); | |
| 51 | } | ||
| 52 | |||
| 53 | |||
| 54 | 6 | ▶ | sub list_defined { |
|
Subroutine
list_defined: called CC=1 SCAR=0.0
Pod
documented
| |||
| 55 | 6 | return grep(defined($_[0]->{$_}), @_); | |
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | 6 | ▶ | sub list_defined_unique { |
|
Subroutine
list_defined_unique: called CC=1 SCAR=0.0
Pod
documented
| |||
| 60 | 6 | my %seen; | |
| 61 | 6 | return grep(defined($_[0]->{$_}), grep(!$seen{$_}++, @_)); | |
| 62 | } | ||
| 63 | |||
| 64 | |||
| 65 | 6 | ▶ | sub num_defined { |
|
Subroutine
num_defined: called CC=1 SCAR=0.0
Pod
documented
| |||
| 66 | 6 | return scalar grep(defined($_[0]->{$_}), @_); | |
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | 6 | ▶ | sub num_defined_unique { |
|
Subroutine
num_defined_unique: called CC=1 SCAR=0.0
Pod
documented
| |||
| 71 | 6 | my %seen; | |
| 72 | 6 | return scalar grep(defined($_[0]->{$_}), grep(!$seen{$_}++, @_)); | |
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | 2 | 1; | |
| 78 | |||
| 79 | __END__ | ||