Formatting real numbers for output
Posted on 1997-07-01
This should be a piece of cake to all you die-hard Perl spods out there, but I don't have the time to trawl through the net and find what I need, and I don't have any printed Perl literature that I can consult. Learning a language by hacking other peoples' code is fine as far as it goes, but only if they've ever done what you need to do yourself...
How do I do decimal formatting on real (ie. not integer) numbers in Perl? Basicallly I have a variable which will contain something like 7.333333333333 and I only want to print the first couple of digits after the decimal point.