Base(3pm)
π Base(3pm) β the Convert::Units::Base glow-up β¨
okay bestie, this is the manual page for Base(3pm), aka Convert::Units::Base, and she is the base object for performing unit conversions. yes she's a Perl module. yes she's iconic. let's get into it π«Ά
πΈ NAME πΈ
Convert::Units::Base β the base object that does unit conversions. that's her whole job, she's very focused π
β¨ DESCRIPTION β¨
so the Units package is a whole little collection of modules that parse strings with unit measurements in them β think "12pt" or "3 meters" β and then convert those into some other unit, like "picas" or "inches". literally the glow-up pipeline for numbers π«
underneath all of it there's a base package, Units::Base, and she does all the dirty work. the other modules just show up and define which units they handle and how those units relate to each other. that's the deal π
π¦ Why a Separate Module?
she's intentionally distinct from the Math::Units module. why tho? because Math::Units implies that unit conversions are exact, with one-to-one relationships. and honestly? that's fine for scientific work. it's even fine for some general purpose/real-world uses (like converting Fehrenheight to Celcius). no cap.
but real-world measurement systems are out here conflicting, and it's messy. 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. and outside of that context entirely? a point may be 1/120 or 1/144 inch. it's giving chaos, honestly π
common notations and abbreviations also depend on context. does "12 pt" mean "12 point", "12 parts" or "12 pints"? bestie. bestie. which one.
and even when there's no conflict 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 use different scales as well as systems. different vibes entirely π
π People do not think like computers
not everyone uses the metric system. periodt.
and even less people say things like "5.25 feet". often it's "5 feet, 3 inches" or "5 1/4 feet". the way that humans just refuse to be decimal π
despite having ten fingers and toes, people don't think in tens. they think in twos, threes, fours, twelves, and sixteens. and sometimes they use fractional measurements like quarter-inches, sixteenths-of-an-inch, or half-pints. iconic behavior honestly π
the purpose of this module is to allow people to use the measurement systems they are familiar with, and that is appropriate to what they are doing. that's the whole point, and she ate π
π Rationale
the Units:: hierarchy is an attempt to keep measurement systems in distinct classes. so you can have modules for converting between typography units (points, picas) that are distinct from common units of length (or area, temperature, etc.), plus specialized units (for Astronomy, Chemistry, Physics, Textiles, Winery, Navigation, etc.) or even traditional or regional systems (Japanese, Chinese, Egyptian, archaic systems, etc.) β and keep all those conflicting measurement systems distinct from each other. no mixing, no drama, just clean little lanes π§
π Release Notes
the current distribution contains the following packages:
Convert::Units::
::Base - a base module that does all of the work
::Length - a module for converting units of length
::Temperature - a module for converting units of temperature
::Type - a module for converting units of type
Units::Base by itself does nothing. she needs a friend!! another module needs to use her to create definitions of what units of measurement it handles and how they are related to each other (ie, 1 m = 100 cm).
the base unit also allows for synonym and abbreviations to be defined. very accommodating of her π
it also allows common "multiples" to be defined, so that it can handle things like "18 half-points" or "6 dozen feet" or even convert millimters to "sixteenths of an inch". (it does not yet handle Greek prefixes like centi- or mega- ... those will have to be manually defined. sigh.)
π Known Issues
the current release should be considered "beta" until further testing and refinements have been made. then again, maybe "alpha" is more accurate π
the current version does not yet handle fractions such as "1/2 in". it should handle decimals such as "0.5 in". okay so fractions are the enemy, noted.
relationships have been rewritten to be handle A(x+b) as well Ax. they may be redone in the future to handle more complex relationships, if the need arises.
β οΈ unit names must be defined as all lowercase, since strings are munged withlc()before processing. in other words, if you define a unit name as"F"or"Fahrenheight"you won't be able to use it. lowercase or perish, bestie.
π₯ Future Enhancements
aside from bug fixes, optimizations, and making the string parsing conform more to the "manifesto" above, the obvious additions would be modules for converting between units of area, volume, weight... (although if Math::Units does what you need, use that instead. respectfully π«Ά)
an example hierarchy for future modules:
Convert::Units::
::Length - general measures of length
::Area
::Pressure
::Volume
Convert::Units::Length
::Chinese - specialized regional/traditional systems
::English
Convert::Units::Astronomy
::Length - or Distance...?
modules should share a common unit (preferably metric) to allow for conversions. teamwork makes the dream work β¨
π REQUIRED MODULES π
Carp
β SEE ALSO β
Units::Length, Units::Temperature and Units::Type modules, which demonstrate how Units::Base is used. go look at them, they're basically her besties showing you how it's done π
πΈ AUTHOR πΈ
Robert Rothenberg <wlkngowl@unix.asb.com>
π LICENSE π
Copyright (c) 1999-2000 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π¦ mwah π this one shipped as perl v5.28.1, dated 2019-05-28 β go forth and convert your units responsibly πβ¨
π¦ where this page comes from
- debian bookworm: libconvert-units-perl 1:0.43-11
- ubuntu jammy: libconvert-units-perl 1:0.43-11
- ubuntu noble: libconvert-units-perl 1:0.43-11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms