File Coverage

blib/lib/Acme/RJWETMORE/Utils.pm
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 18 18 100.0


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