in reply to
The Definitive Unit Conversion Script
I was interested in tye's quip about dealing with unit specifications such as 'kg/m/m' vs 'kg/m^2'...so I started digging around on CPAN for tokenizers that might assist in normalizing unit representations. There's some infix/postfix stuff, as well as various tokenizers such as Math::Expr that might be of assistance here.
Perhaps more importantly, there's some unit conversion modules already out there that might bear further scrutiny:
Of these, the Convert-Units bundle seems to be on the money, since in the author's words:
It is intentionally distinct from the Math::Units module. Why? The
Math::Units module implies that unit conversions are exact,
with one-to-one relationships. This is fine for scientific work.
It's even fine for some general purpose/real-world uses (such as
converting Fehrenheight to Celcius).
Real-world measurement systems are conflicting. For instance, a "point"
in typography is equivalent to 1/72 inch, according to PostScript specs
and common usage. Other type systems consider it 1/72.27 inch, or 0.01383
inches, or 0.0148 inches. Outside of that context, a point may be 1/120
or 1/144 inch.
Common notations and abbreviations also depend on context. Does "12 pt"
mean "12 point", "12 parts" or "12 pints"?
Even without conflicts in the definition of a particular unit, there's no
need to convert point sizes for fonts into miles or light-years. Typesetters,
surveyors and astronomers user different scales as well as systems.
Hope these are of assistance. At the very least, you can mine the modules for conversion tables!