| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormHandler::Merge; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: internal hash merging |
|
3
|
|
|
|
|
|
|
$HTML::FormHandler::Merge::VERSION = '0.40068'; |
|
4
|
145
|
|
|
145
|
|
3965
|
use warnings; |
|
|
145
|
|
|
|
|
365
|
|
|
|
145
|
|
|
|
|
5063
|
|
|
5
|
145
|
|
|
145
|
|
58818
|
use Data::Clone; |
|
|
145
|
|
|
|
|
85850
|
|
|
|
145
|
|
|
|
|
7994
|
|
|
6
|
145
|
|
|
145
|
|
1160
|
use base 'Exporter'; |
|
|
145
|
|
|
|
|
359
|
|
|
|
145
|
|
|
|
|
68045
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = ( 'merge' ); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $matrix = { |
|
11
|
|
|
|
|
|
|
'SCALAR' => { |
|
12
|
|
|
|
|
|
|
'SCALAR' => sub { $_[0] }, |
|
13
|
|
|
|
|
|
|
'ARRAY' => sub { [ $_[0], @{ $_[1] } ] }, |
|
14
|
|
|
|
|
|
|
'HASH' => sub { $_[1] }, |
|
15
|
|
|
|
|
|
|
}, |
|
16
|
|
|
|
|
|
|
'ARRAY' => { |
|
17
|
|
|
|
|
|
|
'SCALAR' => sub { [ @{ $_[0] }, $_[1] ] }, |
|
18
|
|
|
|
|
|
|
'ARRAY' => sub { [ @{ $_[0] }, @{ $_[1] } ] }, |
|
19
|
|
|
|
|
|
|
'HASH' => sub { $_[1] }, |
|
20
|
|
|
|
|
|
|
}, |
|
21
|
|
|
|
|
|
|
'HASH' => { |
|
22
|
|
|
|
|
|
|
'SCALAR' => sub { $_[0] }, |
|
23
|
|
|
|
|
|
|
'ARRAY' => sub { $_[0] }, |
|
24
|
|
|
|
|
|
|
'HASH' => sub { merge_hashes( $_[0], $_[1] ) }, |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub merge { |
|
29
|
151
|
|
|
151
|
0
|
1067
|
my ( $left, $right ) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
151
|
100
|
|
|
|
637
|
my $lefttype = |
|
|
|
100
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
ref $left eq 'HASH' ? 'HASH' : |
|
33
|
|
|
|
|
|
|
ref $left eq 'ARRAY' ? 'ARRAY' : |
|
34
|
|
|
|
|
|
|
'SCALAR'; |
|
35
|
151
|
100
|
|
|
|
567
|
my $righttype = |
|
|
|
100
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
ref $right eq 'HASH' ? 'HASH' : |
|
37
|
|
|
|
|
|
|
ref $right eq 'ARRAY' ? 'ARRAY' : |
|
38
|
|
|
|
|
|
|
'SCALAR'; |
|
39
|
151
|
|
|
|
|
1519
|
$left = clone($left); |
|
40
|
151
|
|
|
|
|
1005
|
$right = clone($right); |
|
41
|
151
|
|
|
|
|
19397
|
return $matrix->{$lefttype}{$righttype}->( $left, $right ); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub merge_hashes { |
|
45
|
145
|
|
|
145
|
0
|
415
|
my ( $left, $right ) = @_; |
|
46
|
145
|
|
|
|
|
329
|
my %newhash; |
|
47
|
145
|
|
|
|
|
537
|
foreach my $leftkey ( keys %$left ) { |
|
48
|
380
|
100
|
|
|
|
960
|
if ( exists $right->{$leftkey} ) { |
|
49
|
12
|
|
|
|
|
55
|
$newhash{$leftkey} = merge( $left->{$leftkey}, $right->{$leftkey} ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
else { |
|
52
|
368
|
|
|
|
|
1377
|
$newhash{$leftkey} = clone( $left->{$leftkey} ); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
145
|
|
|
|
|
519
|
foreach my $rightkey ( keys %$right ) { |
|
56
|
257
|
100
|
|
|
|
17613
|
if ( !exists $left->{$rightkey} ) { |
|
57
|
245
|
|
|
|
|
892
|
$newhash{$rightkey} = clone( $right->{$rightkey} ); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
145
|
|
|
|
|
1590
|
return \%newhash; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding UTF-8 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
HTML::FormHandler::Merge - internal hash merging |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.40068 |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gerda Shank. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
88
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |