line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::SIprefixes::milli; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21245
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
882
|
use bignum; |
|
1
|
|
|
|
|
8245
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
66182
|
use base 'Error::Helper'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
821
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Data::SIprefixes::milli - This provides milli matching for Data::SIprefixes. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.0.0 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.0.0'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Data::SIprefixes::centi; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $prefix=Data::SIprefixes::milli->new; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $origMeasure='millimeter'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $measure=$prefix->longMatch( $origMeasure ); |
29
|
|
|
|
|
|
|
my $long; |
30
|
|
|
|
|
|
|
if ( $prefix->error ){ |
31
|
|
|
|
|
|
|
warn('error:'.$prefix->error.': '.$prefix->errorString); |
32
|
|
|
|
|
|
|
}elseif( ! defined( $measure ) ){ |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$measure=$prefix->shortMatch( $origMeasure ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
}else{ |
37
|
|
|
|
|
|
|
$long=1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 new |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This initiates the object. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $prefix=$Data::SIprefixes::milli->new; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
0
|
|
|
0
|
1
|
|
my $string=$_[1]; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $self={ |
54
|
|
|
|
|
|
|
perror=>undef, |
55
|
|
|
|
|
|
|
error=>undef, |
56
|
|
|
|
|
|
|
errorString=>'', |
57
|
|
|
|
|
|
|
fromBase=>0.001, |
58
|
|
|
|
|
|
|
toBase=>1000, |
59
|
|
|
|
|
|
|
}; |
60
|
0
|
|
|
|
|
|
bless $self; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 fromBase |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns the number needed to to multiple it by to get from the unprefixed |
68
|
|
|
|
|
|
|
measure to the prefixed measure. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $fromBase=$prefix->fromBase; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub fromBase{ |
75
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
78
|
0
|
|
|
|
|
|
$self->warnString('Failed to blank the previous error'); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return $self->fromBase; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 longMatch |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Matches long SI prefixed measures. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
A match returns the measure with out the SI prefix, which will be '' |
89
|
|
|
|
|
|
|
if no measure is specified. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $measure=$prefix->longMatch( $origMeasure ); |
92
|
|
|
|
|
|
|
if ( $prefix->error ){ |
93
|
|
|
|
|
|
|
warn('error:'.$foo->error.': '.$foo->errorString); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub longMatch{ |
99
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
100
|
0
|
|
|
|
|
|
my $measure=$_[1]; |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
103
|
0
|
|
|
|
|
|
$self->warnString('Failed to blank the previous error'); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if ( ! defined( $measure ) ){ |
107
|
0
|
|
|
|
|
|
$self->{error}=1; |
108
|
0
|
|
|
|
|
|
$self->{errorString}='No measure defined'; |
109
|
0
|
|
|
|
|
|
$self->warn; |
110
|
0
|
|
|
|
|
|
return undef; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
if ( $measure=~/^milli/ ){ |
114
|
0
|
|
|
|
|
|
my $origMeasure=$measure; |
115
|
0
|
|
|
|
|
|
$measure=~s/^milli//g; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
if ( $measure =~ /^ / ){ |
118
|
0
|
|
|
|
|
|
$self->{error}=2; |
119
|
0
|
|
|
|
|
|
$self->{errorString}='Space found after prefix, /^milli/, in "'.$origMeasure.'"' ; |
120
|
0
|
|
|
|
|
|
$self->warn; |
121
|
0
|
|
|
|
|
|
return undef; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return $measure; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return undef; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 shortMatch |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Matches short SI prefixed measures. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
A match returns the measure with out the SI prefix, which will be '' |
135
|
|
|
|
|
|
|
if no measure is specified. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $measure=$prefix->longMatch( $origMeasure ); |
138
|
|
|
|
|
|
|
if ( $prefix->error ){ |
139
|
|
|
|
|
|
|
warn('error:'.$foo->error.': '.$foo->errorString); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub shortMatch{ |
145
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
146
|
0
|
|
|
|
|
|
my $measure=$_[1]; |
147
|
|
|
|
|
|
|
|
148
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
149
|
0
|
|
|
|
|
|
$self->warnString('Failed to blank the previous error'); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
if ( ! defined( $measure ) ){ |
153
|
0
|
|
|
|
|
|
$self->{error}=1; |
154
|
0
|
|
|
|
|
|
$self->{errorString}='No measure defined'; |
155
|
0
|
|
|
|
|
|
$self->warn; |
156
|
0
|
|
|
|
|
|
return undef; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# avoids possible collisions |
160
|
0
|
0
|
0
|
|
|
|
if ( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
161
|
|
|
|
|
|
|
( $measure eq 'm' ) || |
162
|
|
|
|
|
|
|
( $measure eq 'meter' ) || |
163
|
|
|
|
|
|
|
( $measure eq 'metre' ) || |
164
|
|
|
|
|
|
|
( $measure eq 'mol' ) || |
165
|
|
|
|
|
|
|
( $measure eq 'mole' ) |
166
|
|
|
|
|
|
|
){ |
167
|
0
|
|
|
|
|
|
return $measure; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
if ( $measure=~/^m/ ){ |
171
|
0
|
|
|
|
|
|
my $origMeasure=$measure; |
172
|
0
|
|
|
|
|
|
$measure=~s/^m//g; |
173
|
|
|
|
|
|
|
|
174
|
0
|
0
|
|
|
|
|
if ( $measure =~ /^ / ){ |
175
|
0
|
|
|
|
|
|
$self->{error}=2; |
176
|
0
|
|
|
|
|
|
$self->{errorString}='Space found after prefix, /^m/, in "'.$origMeasure.'"' ; |
177
|
0
|
|
|
|
|
|
$self->warn; |
178
|
0
|
|
|
|
|
|
return undef; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
return $measure; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
return undef; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 symbol |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This returns the symbol for the prefix. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $symbol=$prefix->symbol; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub symbol{ |
196
|
0
|
|
|
0
|
1
|
|
return 'm'; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 toBase |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Returns the number needed to to multiple it by to get from the prefixed measure |
202
|
|
|
|
|
|
|
number to the unprefixed measure. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
my $toBase=$prefix->toBase; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub toBase{ |
209
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
210
|
|
|
|
|
|
|
|
211
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
212
|
0
|
|
|
|
|
|
$self->warnString('Failed to blank the previous error'); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
return $self->toBase; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 ERROR CODES |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 1 |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Nothing passed for a measure. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 2 |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Space found after prefix. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 AUTHOR |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 BUGS |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
235
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
236
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 SUPPORT |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
perldoc Data::SIprefixes::milli |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
You can also look for information at: |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=over 4 |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
L |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
L |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=item * CPAN Ratings |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
L |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=item * Search CPAN |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
L |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=back |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Copyright 2012 Zane C. Bowers-Hadley. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
279
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
280
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=cut |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
1; # End of Data::SIprefixes::milli |