| 1 | package Number::Denominal; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use List::ToHumanString 1.002; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | our @EXPORT = qw(denominal denominal_hashref denominal_list); | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | our $VERSION = '2.001002'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 600280 | ▶ | sub denominal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
denominal: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 600280 | my ( $num, @den ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 600280 | return _denominal( $num, \@den, 'string' ); | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | ▶ | sub denominal_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
denominal_list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 13 | my ( $num, @den ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | return _denominal( $num, \@den, 'list' ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | ▶ | sub denominal_hashref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
denominal_hashref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 12 | my ( $num, @den ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 12 | return _denominal( $num, \@den, 'hashref' ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 600305 | ▶ | sub _denominal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_denominal: called CC=23 SCAR=31.4
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 600305 | my ( $num, $den, $mode ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 600305 | $num = abs $num; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 600305 | my $args = _prepare_extra_args( $den ); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 600304 | $den = _process_den( $mode, $den ); | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 600304 | my @bits; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 600304 | my $step = 1; # steps for precision, if enabled | |||||||||||||||||||||||||||||||||||||||||
| 37 | 600304 | my $pre_bit; # a "pre" bit, again for precision to handle rounding. | |||||||||||||||||||||||||||||||||||||||||
| 38 | my @ordered_bit_names; # need this for missing bits in denominal_list | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 600304 | for my $bit ( _get_bits( @$den ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 40 | 2107632 | push @ordered_bit_names, $bit->{name}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2107632 | $bit->{num} = sprintf '%d', $num / $bit->{divisor}; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 2107632 | $num = $num - $bit->{num} * $bit->{divisor}; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2107632 | ▶ | if ( @bits | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@bits and $args->{"precision"} and ++$step > $args->{"precision"}
@bits and $args->{"precision"}
MC/DC100%3/3
@bits and $args->{"precision"} and ++$step > $args->{"precision"}
@bits
$args->{"precision"}
++$step > $args->{"precision"}
Truth table100%4/4
A and B and C
A= @bitsB= $args->{"precision"}C= ++$step > $args->{"precision"}
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | and $args->{precision} and ++$step > $args->{precision} | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 300265 | ▶ | last unless $bit->{num}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # add current element and pre bit, for sake of calculations | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # I should really really refactor this crap to something sane | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 257679 | ▶ | unshift @bits, $pre_bit if defined $pre_bit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 257679 | push @bits, +{ %$bit }; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 257679 | for ( reverse 0 .. $#bits ) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | # increase the previous number if we have to round | ||||||||||||||||||||||||||||||||||||||||||
| 57 | $bits[$_-1]{num}++ | ||||||||||||||||||||||||||||||||||||||||||
| 58 | if $bits[$_]{num} * $bits[$_]{divisor} | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 510460 | ▶ | / $bits[$_-1]{divisor} >= 0.5; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | $bits[$_]{num} = 0 | ||||||||||||||||||||||||||||||||||||||||||
| 62 | if $bits[$_]{num} * $bits[$_]{divisor} | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 510460 | ▶ | / $bits[$_-1]{divisor} == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | # stop checking previous numbers if we ran out of them | ||||||||||||||||||||||||||||||||||||||||||
| 66 | # or they haven't reached their limit (divisor) yet. | ||||||||||||||||||||||||||||||||||||||||||
| 67 | last if $_ == 0 | ||||||||||||||||||||||||||||||||||||||||||
| 68 | or $bits[$_-1]{num} * $bits[$_-1]{divisor} | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 510460 | ▶ | < $bits[$_-2]{divisor}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_ == 0 or $bits[$_ - 1]{"num"} * $bits[$_ - 1]{"divisor"} < $bits[$_ - 2]{"divisor"}
MC/DC100%2/2
$_ == 0 or $bits[$_ - 1]{"num"} * $bits[$_ - 1]{"divisor"} < $bits[$_ - 2]{"divisor"}
$_ == 0
$bits[$_ - 1]{"num"} * $bits[$_ - 1]{"divisor"} < $bits[$_ - 2]{"divisor"}
Truth table100%3/3
A or B
A= $_ == 0B= $bits[$_ - 1]{"num"} * $bits[$_ - 1]{"divisor"} < $bits[$_ - 2]{"divisor"}
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | # pop last element off, since it was temporary | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 257679 | pop @bits; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | # get rid of els with zero nums (including pre bit) | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 257679 | @bits = grep $_->{num}, @bits; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 257679 | last; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1807367 | ▶ | $pre_bit = $bit unless $bit->{num}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1807367 | ▶ | $bit->{num} or next; # don't insert the bit, if it's zero | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1630243 | push @bits, +{ %$bit }; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 600304 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 86 | # process the bits into output format, depending on what type | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # ... of output is wanted | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 600304 | for ( @bits ) { | |||||||||||||||||||||||||||||||||||||||||
| 89 | push @result, $mode eq 'hashref' ? ( $_->{name}[0] => $_->{num} ) | ||||||||||||||||||||||||||||||||||||||||||
| 90 | : $mode eq 'list' ? { num => $_->{num}, name => $_->{name}[0] } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 1630240 | ▶ | : $_->{num} . ' ' . $_->{name}[ $_->{num} == 1 ? 0 : 1 ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 600304 | ▶ | if ( $mode eq 'list' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 13 | my @temp_result = @result; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 13 | @result = (); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 13 | my %bits_in_result; | |||||||||||||||||||||||||||||||||||||||||
| 98 | @bits_in_result{ map $_->{name}, @temp_result } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 13 | = map $_->{num}, @temp_result; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 13 | for ( @ordered_bit_names ) { | |||||||||||||||||||||||||||||||||||||||||
| 102 | push @result, exists $bits_in_result{ $_ } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 43 | ▶ | ? $bits_in_result{ $_ } : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 600304 | ▶ | return $mode eq 'hashref' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | ? +{@result} : | ||||||||||||||||||||||||||||||||||||||||||
| 109 | $mode eq 'list' | ||||||||||||||||||||||||||||||||||||||||||
| 110 | ? @result : to_human_string '|list|', @result; | ||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 600304 | ▶ | sub _get_bits { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_bits: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 600304 | my @den = @_; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 600304 | my @bits; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 600304 | my $divisor = 1; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 600304 | for ( grep !($_%2), 0..$#den ) { | |||||||||||||||||||||||||||||||||||||||||
| 119 | 3001454 | ▶ | if ( not ref $den[ $_ ] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 3001433 | $den[ $_ ] = [ | |||||||||||||||||||||||||||||||||||||||||
| 121 | $den[ $_ ], | ||||||||||||||||||||||||||||||||||||||||||
| 122 | $den[ $_ ] . 's', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 3001454 | push @bits, { | |||||||||||||||||||||||||||||||||||||||||
| 127 | name => $den[ $_ ], | ||||||||||||||||||||||||||||||||||||||||||
| 128 | divisor => $divisor, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 3001454 | ▶ | $divisor *= $den[ $_+1 ] || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$den[$_ + 1] || 1
MC/DC100%1/1
$den[$_ + 1] || 1
$den[$_ + 1]
Truth table100%2/2
A
A= $den[$_ + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 600304 | return reverse @bits; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 600304 | ▶ | sub _process_den { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_den: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 600304 | my ( $mode, $den ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 600304 | ▶ | if ( @$den == 1 and ref $den->[0] eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
@$den == 1 and ref $den->[0] eq "ARRAY"
MC/DC100%2/2
@$den == 1 and ref $den->[0] eq "ARRAY"
@$den == 1
ref $den->[0] eq "ARRAY"
Truth table100%3/3
A and B
A= @$den == 1B= ref $den->[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | my $idx = 0; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | @$den = map +( 'el' . $idx++ => $_ ), @{ $den->[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | push @$den, 'el', $idx; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | $mode = 'list'; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | ▶ | elsif ( @$den == 1 and ref $den->[0] eq 'SCALAR' ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
@$den == 1 and ref $den->[0] eq "SCALAR"
MC/DC50%1/2
@$den == 1 and ref $den->[0] eq "SCALAR"
@$den == 1
ref $den->[0] eq "SCALAR"
Truth table66%2/3
A and B
A= @$den == 1B= ref $den->[0] eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 600271 | my $unit_shortcut = ${ $den->[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 600271 | my $values_for_unit = _get_units()->{ $unit_shortcut }; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 600271 | ▶ | croak qq{Unknown unit shortcut ``$unit_shortcut''} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | unless $values_for_unit; | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 600271 | $den = $values_for_unit; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 600304 | return $den; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 600305 | ▶ | sub _prepare_extra_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_extra_args: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 600305 | my $den = shift; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 600305 | ▶ | return unless ref $den->[-1] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 300271 | my %extra_args = %{ delete $den->[-1] }; | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 300271 | ▶ | if ( exists $extra_args{precision} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 300271 | my $p = $extra_args{precision}; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 300271 | ▶ | croak q{precision argument takes positive integers only,} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$p and $p =~ /\A\d+\z/
MC/DC50%1/2
$p and $p =~ /\A\d+\z/
$p
$p =~ /\A\d+\z/
Truth table66%2/3
A and B
A= $pB= $p =~ /\A\d+\z/
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | . q{ but its value is } . (defined $p ? $p : '[undefined]') | ||||||||||||||||||||||||||||||||||||||||||
| 169 | unless $p and $p =~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 300270 | return \%extra_args; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 600272 | ▶ | sub _get_units { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_units: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 600272 | time => [ | |||||||||||||||||||||||||||||||||||||||||
| 178 | second => 60 => minute => 60 => hour => 24 => day => 7 => 'week' | ||||||||||||||||||||||||||||||||||||||||||
| 179 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 180 | weight => [ | ||||||||||||||||||||||||||||||||||||||||||
| 181 | gram => 1000 => kilogram => 1000 => 'tonne', | ||||||||||||||||||||||||||||||||||||||||||
| 182 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 183 | weight_imperial => [ | ||||||||||||||||||||||||||||||||||||||||||
| 184 | ounce => 16 => pound => 14 => stone => 160 => 'ton', | ||||||||||||||||||||||||||||||||||||||||||
| 185 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 186 | length => [ | ||||||||||||||||||||||||||||||||||||||||||
| 187 | meter => 1000 => kilometer => 9_460_730_472.5808 => 'light year', | ||||||||||||||||||||||||||||||||||||||||||
| 188 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 189 | length_mm => [ | ||||||||||||||||||||||||||||||||||||||||||
| 190 | millimeter => 10 => centimeter => 100 => meter => 1000 | ||||||||||||||||||||||||||||||||||||||||||
| 191 | => kilometer => 9_460_730_472.5808 => 'light year', | ||||||||||||||||||||||||||||||||||||||||||
| 192 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 193 | length_imperial => [ | ||||||||||||||||||||||||||||||||||||||||||
| 194 | [qw/inch inches/] => 12 => | ||||||||||||||||||||||||||||||||||||||||||
| 195 | [qw/foot feet/] => 3 => yard => 1760 | ||||||||||||||||||||||||||||||||||||||||||
| 196 | => [qw/mile miles/], | ||||||||||||||||||||||||||||||||||||||||||
| 197 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 198 | volume => [ | ||||||||||||||||||||||||||||||||||||||||||
| 199 | milliliter => 1000 => 'Liter', | ||||||||||||||||||||||||||||||||||||||||||
| 200 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 201 | volume_imperial => [ | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 'fluid ounce' => 20 => pint => 2 => quart => 4 => 'gallon', | ||||||||||||||||||||||||||||||||||||||||||
| 203 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 204 | info => [ | ||||||||||||||||||||||||||||||||||||||||||
| 205 | bit => 8 => byte => 1000 => kilobyte => 1000 => megabyte => 1000 | ||||||||||||||||||||||||||||||||||||||||||
| 206 | => gigabyte => 1000 => terabyte => 1000 => petabyte => 1000 | ||||||||||||||||||||||||||||||||||||||||||
| 207 | => exabyte => 1000 => zettabyte => 1000 => 'yottabyte', | ||||||||||||||||||||||||||||||||||||||||||
| 208 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 209 | info_1024 => [ | ||||||||||||||||||||||||||||||||||||||||||
| 210 | bit => 8 => byte => 1024 => kibibyte => 1024 => mebibyte => 1024 | ||||||||||||||||||||||||||||||||||||||||||
| 211 | => gibibyte => 1024 => tebibyte => 1024 => pebibyte => 1024 | ||||||||||||||||||||||||||||||||||||||||||
| 212 | => exbibyte => 1024 => zebibyte => 1024 => 'yobibyte', | ||||||||||||||||||||||||||||||||||||||||||
| 213 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 214 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 9 | q| | |||||||||||||||||||||||||||||||||||||||||
| 218 | Q: how many programmers does it take to change a light bulb? | ||||||||||||||||||||||||||||||||||||||||||
| 219 | A: none, that's a hardware problem | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |; | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | __END__ | ||||||||||||||||||||||||||||||||||||||||||