line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86894
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(is_number); |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
8
|
1
|
|
|
1
|
|
360
|
use List::Util qw(all sum); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
9
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
10
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
11
|
1
|
|
|
1
|
|
286
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
12
|
1
|
|
|
1
|
|
613
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
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
|
|
34
|
if_array_ref => sub { |
20
|
|
|
|
|
|
|
my $val = $_[0]; |
21
|
|
|
|
|
|
|
return undef, 1 unless all {is_number($_)} @$val; |
22
|
5
|
|
|
5
|
|
7
|
sum(@$val) // 0; |
23
|
5
|
100
|
|
|
|
19
|
} |
|
17
|
|
|
|
|
51
|
|
24
|
4
|
|
50
|
|
|
78
|
); |
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 |