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!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||