line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::Unique; |
2
|
1
|
|
|
1
|
|
660
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
171
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.05"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub get_unique_hash { |
9
|
0
|
|
|
0
|
1
|
|
(my $array_hash, my $key) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my @tmp; |
12
|
0
|
|
|
|
|
|
my @return_hash = (); |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
foreach my $hash (@$array_hash) { |
15
|
0
|
0
|
|
|
|
|
if (!in_array($hash->{$key}, \@tmp)) { |
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
|
|
|
0
|
0
|
|
(my $val, my $array_ref) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
foreach my $elem (@$array_ref) { |
28
|
0
|
0
|
|
|
|
|
if ($val eq $elem) { |
29
|
0
|
|
|
|
|
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |