line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Deep::Hash::Exists;
|
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
123778
|
use strict;
|
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
96
|
|
4
|
4
|
|
|
4
|
|
18
|
use warnings;
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
98
|
|
5
|
4
|
|
|
4
|
|
3207
|
use utf8;
|
|
4
|
|
|
|
|
42
|
|
|
4
|
|
|
|
|
20
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
109
|
use base qw( Exporter );
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1373
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw();
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(
|
11
|
|
|
|
|
|
|
key_exists
|
12
|
|
|
|
|
|
|
every_keys
|
13
|
|
|
|
|
|
|
some_keys
|
14
|
|
|
|
|
|
|
);
|
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => [ @EXPORT, @EXPORT_OK ] );
|
16
|
|
|
|
|
|
|
our $VERSION = '0.2';
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub key_exists($$) {
|
19
|
25
|
|
|
25
|
1
|
120
|
my $hash_ref = shift;
|
20
|
25
|
|
|
|
|
32
|
my $array_ref = shift;
|
21
|
|
|
|
|
|
|
|
22
|
25
|
100
|
|
|
|
81
|
return 0 if ref $hash_ref ne 'HASH';
|
23
|
|
|
|
|
|
|
|
24
|
22
|
|
|
|
|
34
|
my $key = shift @$array_ref;
|
25
|
|
|
|
|
|
|
|
26
|
22
|
100
|
|
|
|
54
|
if ( exists $hash_ref->{$key} ) {
|
27
|
18
|
100
|
|
|
|
41
|
if ( scalar @$array_ref > 0 ) {
|
28
|
9
|
|
|
|
|
24
|
return &key_exists( $hash_ref->{$key}, $array_ref );
|
29
|
|
|
|
|
|
|
} else {
|
30
|
9
|
|
|
|
|
45
|
return 1;
|
31
|
|
|
|
|
|
|
}#fi
|
32
|
|
|
|
|
|
|
} else {
|
33
|
4
|
|
|
|
|
20
|
return 0;
|
34
|
|
|
|
|
|
|
}#fi
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub every_keys($$) {
|
38
|
2
|
|
|
2
|
1
|
23
|
my $hash_ref = shift;
|
39
|
2
|
|
|
|
|
3
|
my $list_array_ref = shift;
|
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
5
|
foreach my $array_ref ( @$list_array_ref ) {
|
42
|
5
|
100
|
|
|
|
12
|
return 0 unless key_exists( $hash_ref, $array_ref );
|
43
|
|
|
|
|
|
|
}#hcaerof
|
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
7
|
return 1;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub some_keys($$) {
|
49
|
2
|
|
|
2
|
1
|
22
|
my $hash_ref = shift;
|
50
|
2
|
|
|
|
|
4
|
my $list_array_ref = shift;
|
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
4
|
foreach my $array_ref ( @$list_array_ref ) {
|
53
|
4
|
100
|
|
|
|
9
|
return 1 if key_exists( $hash_ref, $array_ref );
|
54
|
|
|
|
|
|
|
}#hcaerof
|
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
4
|
return 0;
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1;
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__
|