| 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
| |||||||||||
| 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
| |||||||||||
| 29 | 0 | return 1; | |||||||||
| 30 | } | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | return 0; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 1 | 1; | |||||||||
| 37 | __END__ | ||||||||||