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