Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.


Fun with Filters

I came about this in a kinda roundabout way. I work in Genomics, a home of freakin' huge data sets. I'm involved in trying to extract and usable QC data from the huge dumps of data coming from our sequencers. Specifically, at the moment I'm trying to make a tree showing all the data and the size of each directory, so I can tell what to copy and what to keep still. I'm using stat to get the file sizes, but that's in bytes, and once you get a few dozen digits in, it kinda gets hairy.

Complicating issues, the code is run on the sequencer, which I (rightly) do not have root privileges for. I took the output from the machine (thanks, SSHFS) and used this code to get human-readable output.
use Modern::Perl ;
use Number::Bytes::Human qw(format_bytes) ;

while ( my $a = <STDIN> ) {
$a =~ s{\b(\d+)\b}{ format_bytes( $1 ) }egmx ;
say $a ;

I love filters. So easy. And Number::Bytes::Human kept me from having to write my own code to convert. Yay, CPAN!