Utils/Hash.pm

filter: Statementstmt 66.6% 24 / 36 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 62.7% 32 / 51 CC 5 SCAR 25.7
CC
5
Cov
57%
get_inner_hash_value
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 13.1
« Utils/Array.pm ↑ Summary Utils/File.pm »
1 #===============================================
2 package Banal::Utils::Hash;
3  
4 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 require Exporter;
11  
12 2 our @ISA = qw(Exporter);
13 2 our @EXPORT_OK = qw(get_inner_hash_value);
14  
15  
16 2 ▶use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 #-----------------------------------------------
21 # get_inner_hash_value($hash, @$keys) -- Given a list of keys, get the associated "value" in an inner hash.
22 # Assumes that all inner levels (except the obtained value) are also HASH references.
23 #...............................................
24 # Function (NOT a method)
25 #-----------------------------------------------
26 0 ▶sub get_inner_hash_value {
Subroutine get_inner_hash_value: not called CC=5 SCAR=34.0
Pod documented
27 0 my $hash = shift;
28 0 my $keys = [@_];
29 0 my $key = pop @$keys;
30
31 0 my $h = $hash;
32 0 foreach my $k (@$keys) {
33 0 ▶ return undef unless (reftype($h) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::reftype($h) eq "HASH" 0 0 0
34 0 ▶ if (exists ($h->{$k})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $h->{$k}) { } 0 0 0
35 0 $h = $h->{$k};
36 }else {
37 0 return undef;
38 }
39 }
40
41 0 ▶ if (exists ($h->{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $h->{$key}) 0 0 0
42 0 return $h->{$key};
43 }
44 0 return undef;
45 }
46  
47  
48  
49  
50  
51 2 1;
52  
53 __END__
« Utils/Array.pm ↑ Summary Utils/File.pm »