Perl Monk, Perl Meditation | |
PerlMonks |
Re^2: GB, MB, KB and on..by glenn (Scribe) |
on Oct 21, 2013 at 13:12 UTC ( [id://1059107]=note: print w/replies, xml ) | Need Help?? |
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>
In Section
Seekers of Perl Wisdom
|
|