I've been overworked for months. I'm on the road this week. I spoke at a user group meeting last night and spent nearly four hours driving back and forth just to get to the hotel late and I overslept a bit.
These are probably not opportune times to be coding, but adding nicer directory listings to Jellybean, I wondered if there was a module to convert file sizes in raw bytes to nicer suffixed equivalents. Not finding anything called File::Size in the first ten pages of CPAN results, I threw together some tests and wrote my own:
my $size = shift;
return $size if $size < 1024;
for my $unit (qw( k M G T P E ))
return int( $size ) . $unit if $size < 1024;
There's an elegance I like, but if it's not so useful, I won't package it for the CPAN. Opinions? (If you saw an earlier version that skipped terabytes and petabytes, I've already fixed that!)