line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::NAHCNUJ::Utils; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
140843
|
use 5.006; |
|
2
|
|
|
|
|
19
|
|
4
|
2
|
|
|
2
|
|
17
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
97
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
16
|
use Exporter qw(import); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
304
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(sum); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Acme::NAHCNUJ::Utils - Answer for exercise 21.3 of the book "Intermediate Perl" |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.01 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Calculates the summation of list. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use Acme::NAHCNUJ::Utils; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $foo = sum(1, 2, 3); #=> 6 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 EXPORT |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
A list of functions that can be exported. You can delete this section |
34
|
|
|
|
|
|
|
if you don't export anything, such as for a purely object-oriented module. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 sum |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Calculates the summation of list. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub sum { |
45
|
7
|
|
|
7
|
1
|
1018
|
my @numbers = grep { defined $_ } @_; |
|
12
|
|
|
|
|
34
|
|
46
|
7
|
|
|
|
|
11
|
my $sum; |
47
|
7
|
|
|
|
|
91
|
$sum += $_ for @numbers; |
48
|
7
|
|
|
|
|
43
|
$sum; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 AUTHOR |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Junichi Hayashi, C<< >> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 BUGS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
58
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
59
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SUPPORT |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
perldoc Acme::NAHCNUJ::Utils |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
You can also look for information at: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over 4 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * CPAN Ratings |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * Search CPAN |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=back |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Copyright 2018 Junichi Hayashi. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
102
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
103
|
|
|
|
|
|
|
copy of the full license at: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
108
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
109
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
110
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
113
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
114
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
117
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
120
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
121
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
122
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
123
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
124
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
125
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
126
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
129
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
130
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
131
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
132
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
133
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
134
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
135
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; # End of Acme::NAHCNUJ::Utils |