line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Measure::Length; |
2
|
1
|
|
|
1
|
|
187232
|
use 5.008001; |
|
1
|
|
|
|
|
9
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=encoding utf8 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Class::Measure::Length - Calculate measurements of length. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Class::Measure::Length; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
print length( 2, 'km' )->meters(); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
4
|
use base qw( Class::Measure ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
348
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
7
|
use Sub::Exporter -setup => { |
24
|
|
|
|
|
|
|
exports => [qw( length )] |
25
|
1
|
|
|
1
|
|
529
|
}; |
|
1
|
|
|
|
|
9694
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This module inherits all the methods made available by |
30
|
|
|
|
|
|
|
L. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 length |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$m = length( 2, 'metres' ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Creates a new measurement object. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
2
|
1
|
20
|
sub length { return __PACKAGE__->new(@_); } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 UNITS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 International System of Units |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Also known as SI and "metric", this unit of measure |
47
|
|
|
|
|
|
|
includes the following. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
kilometre |
50
|
|
|
|
|
|
|
metre |
51
|
|
|
|
|
|
|
centimetre |
52
|
|
|
|
|
|
|
millimetre |
53
|
|
|
|
|
|
|
decimetre |
54
|
|
|
|
|
|
|
micrometre |
55
|
|
|
|
|
|
|
nanometre |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
And all veriations are aliased, such as "m", "meter", |
58
|
|
|
|
|
|
|
"meters", "metres". |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__PACKAGE__->reg_units( |
63
|
|
|
|
|
|
|
qw( kilometre centimetre millimetre decimetre micrometre nanometre metre ) |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
__PACKAGE__->reg_aliases( |
66
|
|
|
|
|
|
|
['kilometer','km','kilometers','kilometres','klick','klicks'] => 'kilometre', |
67
|
|
|
|
|
|
|
['meter','m','meters','metres'] => 'metre', |
68
|
|
|
|
|
|
|
['centimeter','cm','centimeters','centimetres'] => 'centimetre', |
69
|
|
|
|
|
|
|
['millimeter','mm','millimeters','millimetres'] => 'millimetre', |
70
|
|
|
|
|
|
|
['decimeter','decimeters','decimetres'] => 'decimetre', |
71
|
|
|
|
|
|
|
['micrometer','micrometers','micron','microns','micrometres'] => 'micrometre', |
72
|
|
|
|
|
|
|
['nanometer','nanometers','nanometres'] => 'nanometre', |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
__PACKAGE__->reg_convs( |
75
|
|
|
|
|
|
|
'km' => 1000, 'm', |
76
|
|
|
|
|
|
|
100, 'cm' => 'm', |
77
|
|
|
|
|
|
|
10, 'mm' => 'cm', |
78
|
|
|
|
|
|
|
'decimetre' => 10, 'cm', |
79
|
|
|
|
|
|
|
1000, 'microns' => 'mm', |
80
|
|
|
|
|
|
|
1000, 'nanometers' => 'micron', |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 Shared |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
These units are shared by with the US and Imperial |
86
|
|
|
|
|
|
|
unit systems. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
inch |
89
|
|
|
|
|
|
|
foot |
90
|
|
|
|
|
|
|
yard |
91
|
|
|
|
|
|
|
rod |
92
|
|
|
|
|
|
|
mile |
93
|
|
|
|
|
|
|
chain |
94
|
|
|
|
|
|
|
furlong |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
All relevant aliases included. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__PACKAGE__->reg_units( |
101
|
|
|
|
|
|
|
qw( inch foot yard rod mile chain furlong ) |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
__PACKAGE__->reg_aliases( |
104
|
|
|
|
|
|
|
['in','inches'] => 'inch', |
105
|
|
|
|
|
|
|
['feet','ft'] => 'foot', |
106
|
|
|
|
|
|
|
'yards' => 'yard', |
107
|
|
|
|
|
|
|
['pole','poles','perch','perches','rods'] => 'rod', |
108
|
|
|
|
|
|
|
'miles' => 'mile', |
109
|
|
|
|
|
|
|
'chains' => 'chain', |
110
|
|
|
|
|
|
|
'furlongs' => 'furlong', |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
__PACKAGE__->reg_convs( |
113
|
|
|
|
|
|
|
'inch' => 25.4, 'mm', |
114
|
|
|
|
|
|
|
'foot' => 12, 'inches', |
115
|
|
|
|
|
|
|
'yard' => 3, 'feet', |
116
|
|
|
|
|
|
|
'yard' => 91.44, 'cm', |
117
|
|
|
|
|
|
|
'rod' => 16.5, 'feet', |
118
|
|
|
|
|
|
|
'mile' => 1.609344, 'km', |
119
|
|
|
|
|
|
|
'mile' => 5280, 'feet', |
120
|
|
|
|
|
|
|
'chain' => 66, 'feet', |
121
|
|
|
|
|
|
|
'furlong' => 10, 'chains', |
122
|
|
|
|
|
|
|
); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 United Stats |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Units specific to the United States. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
survey_mile |
129
|
|
|
|
|
|
|
link |
130
|
|
|
|
|
|
|
fathom |
131
|
|
|
|
|
|
|
cable_length |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Aliases included. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__PACKAGE__->reg_units( |
138
|
|
|
|
|
|
|
qw( survey_mile link fathom cable_length ) |
139
|
|
|
|
|
|
|
); |
140
|
|
|
|
|
|
|
__PACKAGE__->reg_aliases( |
141
|
|
|
|
|
|
|
'survey_miles' => 'survey_mile', |
142
|
|
|
|
|
|
|
'links' => 'link', |
143
|
|
|
|
|
|
|
'fathoms' => 'fathom', |
144
|
|
|
|
|
|
|
'cable_lengths' => 'cable_length', |
145
|
|
|
|
|
|
|
); |
146
|
|
|
|
|
|
|
__PACKAGE__->reg_convs( |
147
|
|
|
|
|
|
|
'survey_mile' => 8, 'furlongs', |
148
|
|
|
|
|
|
|
'link' => 0.001, 'furlongs', |
149
|
|
|
|
|
|
|
'fathom' => 6, 'feet', |
150
|
|
|
|
|
|
|
'cable_length' => 123, 'fathoms', |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 Imperial |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Imperial (english) units. The only unit included |
156
|
|
|
|
|
|
|
in this set is "league". |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
__PACKAGE__->reg_units( |
161
|
|
|
|
|
|
|
qw( league ) |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
__PACKAGE__->reg_aliases( |
164
|
|
|
|
|
|
|
'leagues' => 'league', |
165
|
|
|
|
|
|
|
); |
166
|
|
|
|
|
|
|
__PACKAGE__->reg_convs( |
167
|
|
|
|
|
|
|
'league' => 3, 'miles', |
168
|
|
|
|
|
|
|
); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 Other |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
light_second |
173
|
|
|
|
|
|
|
nautical_mile |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
__PACKAGE__->reg_units( |
178
|
|
|
|
|
|
|
qw( light_second nautical_mile ) |
179
|
|
|
|
|
|
|
); |
180
|
|
|
|
|
|
|
__PACKAGE__->reg_aliases( |
181
|
|
|
|
|
|
|
'light_seconds' => 'light_second', |
182
|
|
|
|
|
|
|
'nautical_miles' => 'nautical_mile', |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
__PACKAGE__->reg_convs( |
185
|
|
|
|
|
|
|
'light_second' => 299792458, 'm', |
186
|
|
|
|
|
|
|
'nautical_mile' => 1852, 'm', |
187
|
|
|
|
|
|
|
); |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |
190
|
|
|
|
|
|
|
__END__ |