Guest User

Untitled

a guest
Oct 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. sub unitFormat {
  2. my @unit = ("B","KB","MB","GB","TB","PB");
  3. my $index = 0;
  4. my($value) = pop;
  5.  
  6. while($value > 1024) {
  7. $value /= 1024;
  8. $index++;
  9. }
  10.  
  11. $value = sprintf("%.3f",$value);
  12. return "$value $unit[$index]";
  13. }
Add Comment
Please, Sign In to add comment