1 # Units.pl: convert units of measurement
2 # Author: M-J. Dominus (mjd-perl-units-id-iut+buobvys+@plover.com)
3 # License: GPL, Copyright (C) 1996,1999
4 # NOTE: Integrated into blootbot by xk.
14 if ($from =~ /([+-]?[\d\.]+(?:e[+-]?[\d]+)?)\s+(temp[CFK])/){
15 $from = qq|${2}(${1})|;
18 my $units = new IO::File;
19 open $units, '-|', 'units', $from, $to or &::DEBUG("Unable to run units: $!") and return;
20 my $response = readline ($units);
21 if ($response =~ /\s+\*\s+([+-]?[\d\.]+(?:e[+-]?[\d]+)?)/ or $response =~ /\t([+-]?[\d\.]+(?:e[+-]?[\d]+)?)/){
22 &::performStrictReply(sprintf("$from is approximately \002%.6g\002 $to", $1));
25 &::performStrictReply("$from cannot be converted to ${to}: $response");