in reply to Re: GB, MB, KB and on..
in thread GB, MB, KB and on..
Fix if size is larger than PB.
<code>
sub prettyBytes {
my $size = $_[0];
foreach ('b','kb','mb','gb','tb','pb') {
last if $size < 1024;
$size /= 1024;
}
return sprintf("%.2f",$size)."$_";
}
<code>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: GB, MB, KB and on..
by hdb (Monsignor) on Oct 21, 2013 at 14:31 UTC |
In Section
Seekers of Perl Wisdom