line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::Unique; |
2
|
1
|
|
|
1
|
|
685
|
use 5.008001; |
|
1
|
|
|
|
|
3
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
187
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub get_unique_hash { |
9
|
0
|
|
|
0
|
1
|
|
(my $array_hash, my $key) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $tmp; |
12
|
|
|
|
|
|
|
my $return_hash; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
foreach my $hash (@{$array_hash}) { |
|
0
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
if (!in_array($hash->{$key}, $tmp)) { |
16
|
0
|
|
|
|
|
|
push (@{$return_hash}, $hash); |
|
0
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
push (@{$tmp}, $hash->{$key}); |
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return $return_hash; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub in_array { |
25
|
0
|
|
|
0
|
0
|
|
(my $val, my $array_ref) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
foreach my $elem (@{$array_ref}) { |
|
0
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if ($val eq $elem) { |
29
|
0
|
|
|
|
|
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |