http://www.perlmonks.org?node_id=154952
Description: print amount (10 * 1024 * 1024) . "\n";
sub amount
  {
  my $num = shift;
  return "" if ! defined $num || ! $num;
  my ($tag) = "K";

  $num = int (($num + 512) / 1024);

  if ($num >= 10000)
    {
    $num = int (($num + 512) / 1024);
    $tag = "M";
    if ($num >= 10000)
      {
      $num = int (($num + 512) / 1024);
      $tag = "G";
      }
    }

  return "<1K" if ($num < 1);
  return "$num$tag";
  }