Hi, I was processing a bunch of files the other day, and I wanted to get a rough idea of their size.
Oddly enough I could not find anything that seemed to be doing this. So I wrote Format::FileSize, which exports 1 function, named formatted_size, perl -MFormat::FileSize -le'foreach (@ARGV) { printf "%-12d => %s\n", $_, formatted_size( $_) }' \ 0 1 500 1023 1024 1025 2500 25000 \ 250000 1000000 25000000 250000000 \ 2500000000 0 => 0 1 => 1 500 => 500 1023 => 1023 1024 => 1 K 1025 => 1 K 2500 => 2.44 K 25000 => 24.4 K 250000 => 244 K 1000000 => 976 K 25000000 => 23.8 M 250000000 => 238 M -1794967296 => 2.32 G Does this make sense or does this already exist and I have missed it? Is Format::FileSize a proper name? A first version is available at http://www.xmltwig.com/module/format-filesize/ Thanks Michel Rodriguez Perl & XML http://www.xmltwig.com