The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Convert::Pluggable - convert between various units of measurement

VERSION

Version 0.016

SYNOPSIS

convert between various units of measurement

use Convert::Pluggable;

...

my $result = $c-convert( { 'factor' => '5', 'fromUnit' => 'feet', 'toUnit' => 'inches', 'precision' => '3', } ); >

will produce '60.000'.

See Convert-Pluggable.t for many more example uses.

See https://ddh5.duckduckgo.com/?q=10000+minutes+in+microseconds for test uses

EXPORT

convert

SUBROUTINES/METHODS

new()

Create a new Conversion object.

convert_temperatures()

A function for converting between various temperature units. Currently supports Fahrenheit, Celsius, Kelvin, Rankine, and Raumur.

convert()

This is the workhorse. All conversion work (except for temperatures) gets done here. This is the only exported sub.

get_matches()

  • get factors for later calculating conversion

  • get trigger 'types' to determine if we can perform a calculation in the first place

  • get canoncial units for massaging output

  • determine if a unit may be negative

    This gets some useful metadata for convert() to carry out its work.

get_units()

This is where you add new unit types so that convert() can operate on them. Currently supported units of measurement are: mass, length, time, pressure, energy, power, angle, force, temperature, digital.

AUTHOR

bradley andersen, <bradley at pvnp.us>

BUGS

SUPPORT

You can find documentation for this module with the perldoc command.

You can also look for information at:

ACKNOWLEDGEMENTS

Special thanks to @mintsoft and @jagtalon

LICENSE AND COPYRIGHT

Copyright 2014 bradley andersen.

No specific license yet.

PRIOR ART

Bot::BasicBot::Pluggable::Module::Convert

relies on

Math::Units

TODO

  • add DDG massaging later if useful

  • better error handling

  • all args to functions should be hash refs!

  • store units data in a file?

  • add more unit types (digital, cooking, etc.)

  • add more tests and better test output

  • fix this documentation!

  • what happens when two units have the same notation? (e.g., 'kilometer' and 'kilobyte' both can use 'K')