While I must second the use of map and sprintf, you may be interested to know that rounding constitutes several Categorized Questions and Answers, is found in perlfaq4, and a fairly common question. In the interest of completness (and TimToady), there are other methods to round numbers as shown in a variety of threads (eg Re: Rounding function and Re^2: Splitting String???), which include the following:
int ($num + .5); ($num += 5 / (10 ** ($decimal_places + 1))) =~ s/(?<=\.)(\d{1,$decimal +_places}).*$/$1/;
In addition to Zaxo's use of map, you may also be interested in using $, (or $" if interpolated; see perlvar), and printing directly, eg:
$, = $/; print map { sprintf("%.2f", $_) } values %stats;
In reply to Re: rounding off all members of a hash
by eibwen
in thread rounding off all members of a hash
by vindaloo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |