#!/usr/bin/perl # convert.pl - convert between units # # 2005-01-08 muttley BEGIN { eval qq{ use Math::Units; }; $no_convert++ if($@); } sub convert { my($From, $To, $Amount) = @_; return "Unit conversion not working" if $no_convert; my $val; eval { $val = Math::Units::convert($Amount, $From, $To) }; return "Hrrm - $@" if $@; return "Dunno about that" unless defined $val && $val !~ m!^\s*$!; return "$Amount $From is $val $To"; } "That's all folks ;-)"; __END__ =head1 NAME convert.pl - convert between units =head1 PREREQUISITES Math::Calc::Units =head1 PARAMETERS =head1 PUBLIC INTERFACE Convert for|[in]to =head1 AUTHORS muttley =cut