blib/lib/Hash/Unique.pm

filter: Statementstmt 38.4% 10 / 26 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 50.0% 1 / 2 totaltotal 37.8% 14 / 37 CC 5 SCAR 21.2
CC
5
Cov
33%
get_unique_hash
12.0
in_array
12.0
BEGIN
1.0
CRAP 8.3
↑ Summary Build »
1 package Hash::Unique;
2 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = "0.03";
7  
8 sub get_unique_hash {
9 0 ▶ (my $array_hash, my $key) = @_;
Subroutine get_unique_hash: not called CC=3 SCAR=24.8
Pod documented
10  
11 0 my $tmp;
12 my $return_hash;
13  
14 0 foreach my $hash (@{$array_hash}) {
15 0 ▶ if (!in_array($hash->{$key}, $tmp)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (in_array($hash->{$key}, $tmp)) 0 0 0
16 0 push (@{$return_hash}, $hash);
17 0 push (@{$tmp}, $hash->{$key});
18 }
19 }
20  
21 0 return $return_hash;
22 }
23  
24 sub in_array {
25 0 ▶ (my $val, my $array_ref) = @_;
Subroutine in_array: not called CC=3 SCAR=24.8
Pod undocumented
26  
27 0 foreach my $elem (@{$array_ref}) {
28 0 ▶ if ($val eq $elem) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq $elem) 0 0 0
29 0 return 1;
30 }
31 }
32  
33 0 return 0;
34 }
35  
36 1 1;
37 __END__
↑ Summary Build »