http://qs1969.pair.com?node_id=378580


in reply to GB, MB, KB and on..

sub scaledbytes { (sort { length $a <=> length $b } map { sprintf '%.3g%s', $_[0]/1024**$_->[1], $_->[0] } [" bytes"=>0],[KB=>1],[MB=>2],[GB=>3],[TB=>4],[PB=>5],[EB=>6])[0] }
Update: don't need none of those stinkin' semicolons. Feels kind of funny to use %g but filter out all the exponential forms (unless that's all there are).