/usr/share/perl5/Math/Calc/Units/Convert/Base2Metric.pm is in libmath-calc-units-perl 1.07-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | package Math::Calc::Units::Convert::Base2Metric;
use base 'Math::Calc::Units::Convert::Metric'; # Overrides
use strict;
use vars qw(%metric_base2 %abbrev $metric_prefix_test %pref);
%metric_base2 = ( kilo => 2**10,
mega => 2**20,
giga => 2**30,
tera => 2**40,
peta => 2**50,
exa => 2**60,
);
# No nanobytes, sorry
%abbrev = ( k => 'kilo',
m => 'mega',
g => 'giga',
t => 'tera',
p => 'peta',
e => 'exa',
);
%pref = ( unit => 1.0,
kilo => 0.8,
mega => 0.8,
giga => 0.8,
tera => 0.7,
peta => 0.6,
exa => 0.3,
);
sub get_metric {
my ($self, $what) = @_;
return $metric_base2{$what};
}
sub get_abbrev {
my ($self, $what) = @_;
return $abbrev{$what} || $abbrev{lc($what)};
}
$metric_prefix_test = qr/^(${\join("|",keys %metric_base2)})/i;
sub get_prefix {
my ($self, $what) = @_;
if ($what =~ $metric_prefix_test) {
return $1;
} else {
return;
}
}
sub prefix_pref {
my ($self, $prefix) = @_;
return $pref{lc($prefix)} || $pref{unit};
}
sub get_prefixes {
return keys %metric_base2;
}
# Unnecessary efficiency hack: don't bother checking both upper & lower case
sub expand {
my ($self, $char) = @_;
return $self->get_abbrev($char);
}
1;
|