in reply to File Size Conversion

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)

--
<http://www.dave.org.uk>

Perl Training in the UK <http://www.iterative-software.com>

Replies are listed 'Best First'.
Re: Re: File Size Conversion
by LostS (Friar) on Aug 14, 2001 at 19:06 UTC
    That works wonderfully :) Thank you sooo much :)