line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86373
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(is_number); |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
8
|
1
|
|
|
1
|
|
349
|
use List::Util qw(all sum); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
9
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
45
|
|
10
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
290
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
12
|
1
|
|
|
1
|
|
631
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
13
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
as_path($self->path)->updater( |
19
|
5
|
|
|
5
|
|
35
|
if_array_ref => sub { |
20
|
|
|
|
|
|
|
my $val = $_[0]; |
21
|
|
|
|
|
|
|
return undef, 1 unless all {is_number($_)} @$val; |
22
|
5
|
|
|
5
|
|
11
|
sum(@$val) // 0; |
23
|
5
|
100
|
|
|
|
19
|
} |
|
17
|
|
|
|
|
51
|
|
24
|
4
|
|
50
|
|
|
75
|
); |
25
|
|
|
|
|
|
|
} |
26
|
5
|
|
|
|
|
16
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Catmandu::Fix::sum - replace the value of an array field with the sum of its elements |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# e.g. numbers => [2, 3] |
39
|
|
|
|
|
|
|
sum(numbers) |
40
|
|
|
|
|
|
|
# numbers => 5 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SEE ALSO |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
L<Catmandu::Fix> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |