line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hash::Diff; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
196849
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
162
|
|
4
|
4
|
|
|
4
|
|
27
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
179
|
|
5
|
4
|
|
|
4
|
|
25
|
use Carp; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
404
|
|
6
|
4
|
|
|
4
|
|
3030
|
use Hash::Merge; |
|
4
|
|
|
|
|
22255
|
|
|
4
|
|
|
|
|
300
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
39
|
use base 'Exporter'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
417
|
|
9
|
4
|
|
|
4
|
|
25
|
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1349
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = 0.008; |
12
|
|
|
|
|
|
|
@EXPORT_OK = qw( diff left_diff ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub left_diff { |
15
|
16
|
|
|
16
|
1
|
126
|
my ($h1, $h2) = @_; |
16
|
16
|
|
|
|
|
27
|
my $rh = {}; # return_hash |
17
|
|
|
|
|
|
|
|
18
|
16
|
|
|
|
|
19
|
foreach my $k (keys %{$h1}) { |
|
16
|
|
|
|
|
55
|
|
19
|
24
|
50
|
33
|
|
|
266
|
if (not defined $h1->{$k} and exists $h2->{$k} and not defined $h2->{$k}) { |
|
|
100
|
0
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
20
|
|
|
|
|
|
|
# Empty |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif (ref $h1->{$k} eq 'HASH') { |
23
|
6
|
50
|
|
|
|
16
|
if (ref $h2->{$k} eq 'HASH') { |
24
|
6
|
|
|
|
|
20
|
my $d = left_diff($h1->{$k}, $h2->{$k}); |
25
|
6
|
100
|
|
|
|
33
|
$rh->{$k} = $d if (%$d); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
0
|
|
|
|
|
0
|
$rh->{$k} = $h1->{$k} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif ((!defined $h2->{$k})||($h1->{$k} ne $h2->{$k})) { |
32
|
8
|
|
|
|
|
25
|
$rh->{$k} = $h1->{$k} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
16
|
|
|
|
|
57
|
return $rh; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub diff { |
41
|
5
|
|
|
5
|
1
|
10434
|
my ($h1, $h2) = @_; |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
21
|
return Hash::Merge::merge(left_diff($h1,$h2),left_diff($h2,$h1)); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |