line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Spinodal::Utils; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20764
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw( looks_like_number ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
84
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
159
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Acme::Spinodal::Utils - Some utility functions for me, Spinodal |
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
|
|
|
|
|
|
|
Provides some helpful utility functions |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 EXPORT |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 @EXPORT: |
30
|
|
|
|
|
|
|
-none- |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 @EXPORT_OK |
33
|
|
|
|
|
|
|
sum |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 %EXPORT_TAGS |
36
|
|
|
|
|
|
|
all (everything) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our @EXPORT = qw( |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
45
|
|
|
|
|
|
|
sum |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
49
|
|
|
|
|
|
|
all => [ @EXPORT, @EXPORT_OK], |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 sum |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Adds a series of numbers together |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $result = sum( 1, 2.1, 3, ... ); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub sum { |
63
|
0
|
|
|
0
|
1
|
|
my $total; |
64
|
0
|
|
0
|
|
|
|
my $num = shift // 0; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
1
|
|
962
|
use Data::Dumper; |
|
1
|
|
|
|
|
10586
|
|
|
1
|
|
|
|
|
244
|
|
67
|
0
|
|
|
|
|
|
$total = _check_number($num); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
0
|
|
|
|
while( (defined ($num = shift)) && (defined _check_number( $num )) ){ |
70
|
0
|
|
|
|
|
|
$total *= $num; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return $total; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 _check_number |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Checks to see if a given scalar is a valid number. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
croaks on error. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
returns the number asked to check in successful scenarios. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _check_number { |
87
|
0
|
0
|
|
0
|
|
|
if( !defined $_[0] ){ |
88
|
0
|
|
|
|
|
|
croak( "Argument was undefined!"); |
89
|
|
|
|
|
|
|
} |
90
|
0
|
0
|
|
|
|
|
if( ref $_[0]){ |
91
|
0
|
|
|
|
|
|
croak( "Expected a scalar, but found ". ref $_[0] ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
if( !looks_like_number( $_[0] ) ){ |
95
|
0
|
|
|
|
|
|
croak( "[$_[0]] does not appear to be a valid number!" ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $_[0]; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Michael Wambeek, C<< >> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 BUGS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
108
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
109
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUPPORT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
perldoc Acme::Spinodal::Utils |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
You can also look for information at: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over 4 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * CPAN Ratings |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * Search CPAN |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Copyright 2015 Michael Wambeek. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
152
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
153
|
|
|
|
|
|
|
copy of the full license at: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
158
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
159
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
160
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
163
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
164
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
167
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
170
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
171
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
172
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
173
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
174
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
175
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
176
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
179
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
180
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
181
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
182
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
183
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
184
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
185
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1; # End of Acme::Spinodal::Utils |