On Mon, 9 Aug 2004, SilverFox wrote:
Example: user enter: 59443 Script will output: 58M
I know this isn't getting into the spirit of things, but have you considered simply using the `units` program?
% units
500 units, 54 prefixes
You have: 59443 bytes
You want: megabytes
* 0.056689262
/ 17.640025
You have: 59443 bytes
You want: kilobytes
* 59.443
/ 0.016822839
You have: ^C
% units bytes kilobytes
* 0.001
/ 1000 % units bytes megabytes
* 9.5367432e-07
/ 1048576The nice thing about `units` -- in this context -- is that it lets the user pick the conversion units they want to work with, and also gives hints for converting both to & from the alternate measurement scale.
Of course, working this into a larger program that does other things might be annoying -- in which case your way is better -- but if all you want is the conversions, this is a solved problem :-)
-- Chris Devers
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
