line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Unixish::sum; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
3350
|
use 5.010; |
|
7
|
|
|
|
|
24
|
|
4
|
7
|
|
|
7
|
|
23
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
143
|
|
5
|
7
|
|
|
7
|
|
2330
|
use syntax 'each_on_array'; # to support perl < 5.12 |
|
7
|
|
|
|
|
135230
|
|
|
7
|
|
|
|
|
24
|
|
6
|
7
|
|
|
7
|
|
17875
|
use warnings; |
|
7
|
|
|
|
|
30
|
|
|
7
|
|
|
|
|
150
|
|
7
|
|
|
|
|
|
|
#use Log::Any '$log'; |
8
|
7
|
|
|
7
|
|
29
|
use Scalar::Util 'looks_like_number'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
274
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
2476
|
use Data::Unixish::Util qw(%common_args); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
1492
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.570'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %SPEC; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$SPEC{sum} = { |
17
|
|
|
|
|
|
|
v => 1.1, |
18
|
|
|
|
|
|
|
summary => 'Sum numbers', |
19
|
|
|
|
|
|
|
args => { |
20
|
|
|
|
|
|
|
%common_args, |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
tags => [qw/datatype:num group/], |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
sub sum { |
25
|
7
|
|
|
7
|
1
|
22
|
my %args = @_; |
26
|
7
|
|
|
|
|
20
|
my ($in, $out) = ($args{in}, $args{out}); |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
14
|
my $sum = 0; |
29
|
7
|
|
|
|
|
44
|
while (my ($index, $item) = each @$in) { |
30
|
35
|
100
|
|
|
|
127
|
$sum += $item if looks_like_number($item); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
7
|
|
|
|
|
18
|
push @$out, $sum; |
34
|
7
|
|
|
|
|
21
|
[200, "OK"]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
# ABSTRACT: Sum numbers |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |