Divide by 1024 and use sprintf to get the rounding.
my $bytes = 82591; my $kb = $bytes / 1024; $kb = sprintf('%1.0f', $kb); print "$kb\n";
(So 82,591 bytes is 81 Kb, not 83 Kb)
--Perl Training in the UK <http://www.iterative-software.com>
In reply to Re: File Size Conversion
by davorg
in thread File Size Conversion
by LostS
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |