.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Units 3pm" .TH Units 3pm "2022-10-21" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::Units \- Unit conversion .SH "SYNOPSIS" .IX Header "SYNOPSIS" use Math::Units qw(convert); .PP my \f(CW$out_value\fR = convert($in_value, 'in unit', 'out unit'); .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Math::Units module converts a numeric value in one unit of measurement to some other unit. The units must be compatible, i.e. length can not be converted to volume. If a conversion can not be made an exception is thrown. .PP A combination chaining and reduction algorithm is used to perform the most direct unit conversion possible. Units may be written in several different styles. An abbreviation table is used to convert from common long-form unit names to the (more or less) standard abbreviations that the units module uses internally. All multiplicative unit conversions are cached so that future conversions can be performed very quickly. .PP Too many units, prefixes and abbreviations are supported to list here. See the source code for a complete listing. .SH "TODO" .IX Header "TODO" I believe this module has great potential, if you have any ideas or patches feel free to submit them to rt.cpan.org. .PP \&'units' program test like 'gunits' .PP other tests .PP \&\s-1POD\s0 about what units/abbr/etc can be used with the function .PP general cleanup .PP Mr. Fox's original \s-1TODO:\s0 .PP 1. There should be a set of routines for adding new unit formulas, reductions and conversions. .PP 2. Some conversions can be automatically generated from a reduction. (This has to be done carefully because conversions are bi-directional while reductions *must* be consistently uni-directional.) .PP 3. It would be nice to simplify the default conversions using the yet-to-be-written solution to #2. .PP 4. There are many units (several in the \s-1GNU\s0 unit program for example) that aren't defined here. Since I was (un)fortunately born in the U.S., I have a(n) (in)correct belief of what the standard units are. Please let me know if I've messed anything up! .SH "EXAMPLES" .IX Header "EXAMPLES" print \*(L"5 mm == \*(R", convert(5, 'mm', 'in'), \*(L" inches\en\*(R"; print \*(L"72 degrees Farenheit == \*(R", convert(72, 'F', 'C'), \*(L" degrees Celsius\en\*(R"; print \*(L"1 gallon == \*(R", convert(1, 'gallon', 'cm^3'), \*(L" cubic centimeters\en\*(R"; print \*(L"4500 rpm == \*(R", convert(4500, 'rpm', 'Hz'), \*(L" Hertz\en\*(R";