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