line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::ModeMerge::Mode::SUBTRACT; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2021-08-15'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.360'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
31
|
|
|
31
|
|
444
|
use 5.010; |
|
31
|
|
|
|
|
84
|
|
7
|
31
|
|
|
31
|
|
148
|
use strict; |
|
31
|
|
|
|
|
46
|
|
|
31
|
|
|
|
|
573
|
|
8
|
31
|
|
|
31
|
|
145
|
use warnings; |
|
31
|
|
|
|
|
59
|
|
|
31
|
|
|
|
|
842
|
|
9
|
31
|
|
|
31
|
|
188
|
use Mo qw(build default); |
|
31
|
|
|
|
|
61
|
|
|
31
|
|
|
|
|
167
|
|
10
|
|
|
|
|
|
|
extends 'Data::ModeMerge::Mode::NORMAL'; |
11
|
|
|
|
|
|
|
|
12
|
731
|
|
|
731
|
1
|
1461
|
sub name { 'SUBTRACT' } |
13
|
|
|
|
|
|
|
|
14
|
8230
|
|
|
8230
|
1
|
12102
|
sub precedence_level { 4 } |
15
|
|
|
|
|
|
|
|
16
|
330
|
|
|
330
|
1
|
914
|
sub default_prefix { '-' } |
17
|
|
|
|
|
|
|
|
18
|
330
|
|
|
330
|
1
|
1080
|
sub default_prefix_re { qr/^-/ } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub merge_SCALAR_SCALAR { |
21
|
42
|
|
|
42
|
0
|
92
|
my ($self, $key, $l, $r) = @_; |
22
|
42
|
|
|
|
|
141
|
($key, $l - $r); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub merge_SCALAR_ARRAY { |
26
|
1
|
|
|
1
|
0
|
2
|
my ($self, $key, $l, $r) = @_; |
27
|
1
|
|
|
|
|
3
|
$self->merger->push_error("Can't subtract scalar and array"); |
28
|
1
|
|
|
|
|
2
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub merge_SCALAR_HASH { |
32
|
1
|
|
|
1
|
0
|
3
|
my ($self, $key, $l, $r) = @_; |
33
|
1
|
|
|
|
|
3
|
$self->merger->push_error("Can't subtract scalar and hash"); |
34
|
1
|
|
|
|
|
2
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub merge_ARRAY_SCALAR { |
38
|
1
|
|
|
1
|
0
|
2
|
my ($self, $key, $l, $r) = @_; |
39
|
1
|
|
|
|
|
2
|
$self->merger->push_error("Can't subtract array and scalar"); |
40
|
1
|
|
|
|
|
2
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub merge_ARRAY_ARRAY { |
44
|
4
|
|
|
4
|
0
|
10
|
my ($self, $key, $l, $r) = @_; |
45
|
4
|
|
|
|
|
8
|
my @res; |
46
|
4
|
|
|
|
|
9
|
my $mm = $self->merger; |
47
|
4
|
|
|
|
|
30
|
for (@$l) { |
48
|
12
|
100
|
|
|
|
78
|
push @res, $_ unless $mm->_in($_, $r); |
49
|
|
|
|
|
|
|
} |
50
|
4
|
|
|
|
|
15
|
($key, \@res); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub merge_ARRAY_HASH { |
54
|
2
|
|
|
2
|
0
|
5
|
my ($self, $key, $l, $r) = @_; |
55
|
2
|
|
|
|
|
5
|
$self->merger->push_error("Can't subtract array and hash"); |
56
|
2
|
|
|
|
|
4
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub merge_HASH_SCALAR { |
60
|
1
|
|
|
1
|
0
|
11
|
my ($self, $key, $l, $r) = @_; |
61
|
1
|
|
|
|
|
5
|
$self->merger->push_error("Can't subtract hash and scalar"); |
62
|
1
|
|
|
|
|
3
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub merge_HASH_ARRAY { |
66
|
2
|
|
|
2
|
0
|
4
|
my ($self, $key, $l, $r) = @_; |
67
|
2
|
|
|
|
|
6
|
$self->merger->push_error("Can't subtract hash and array"); |
68
|
2
|
|
|
|
|
13
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub merge_HASH_HASH { |
72
|
3
|
|
|
3
|
0
|
7
|
my ($self, $key, $l, $r) = @_; |
73
|
3
|
|
|
|
|
8
|
my $mm = $self->merger; |
74
|
|
|
|
|
|
|
|
75
|
3
|
|
|
|
|
9
|
my %res; |
76
|
3
|
|
|
|
|
13
|
my $r2 = {}; |
77
|
3
|
|
|
|
|
18
|
for (keys %$r) { |
78
|
5
|
100
|
|
|
|
14
|
my $k = $mm->check_prefix($_) ? $_ : $mm->add_prefix($_, 'DELETE'); |
79
|
5
|
50
|
66
|
|
|
40
|
if ($k ne $_ && exists($r->{$k})) { |
80
|
0
|
|
|
|
|
0
|
$mm->push_error("Conflict when adding DELETE prefix on right-side hash key $_ ". |
81
|
|
|
|
|
|
|
"for SUBTRACT merge: key $k already exists"); |
82
|
0
|
|
|
|
|
0
|
return; |
83
|
|
|
|
|
|
|
} |
84
|
5
|
|
|
|
|
14
|
$r2->{$k} = $r->{$_}; |
85
|
|
|
|
|
|
|
} |
86
|
3
|
|
|
|
|
11
|
$mm->_merge($key, $l, $r2, 'NORMAL'); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
# ABSTRACT: Handler for Data::ModeMerge SUBTRACT merge mode |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding UTF-8 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Data::ModeMerge::Mode::SUBTRACT - Handler for Data::ModeMerge SUBTRACT merge mode |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 VERSION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This document describes version 0.360 of Data::ModeMerge::Mode::SUBTRACT (from Perl distribution Data-ModeMerge), released on 2021-08-15. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SYNOPSIS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
use Data::ModeMerge; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This is the class to handle SUBTRACT merge mode. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=for Pod::Coverage ^merge_.* |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 HOMEPAGE |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Data-ModeMerge>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SOURCE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-ModeMerge>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 BUGS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-ModeMerge> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
129
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
130
|
|
|
|
|
|
|
feature. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This software is copyright (c) 2021, 2016, 2015, 2013, 2012, 2011, 2010 by perlancar <perlancar@cpan.org>. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
141
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |