# An evil collection of one-liners to make this five-line # script which sorts a file by a date field. It's designed # for massive files, and indexes directly into the file. open(FD,"data") || die; my ($loc,@a) = (tell(FD)); push(@a,[$loc,(split /\|/)[4]]),$loc = tell(FD) while(); # 4 is the datefield seek(FD,$_,0), $_ = , print for map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [$_->[0], sprintf "%04d%02d%02d",(split /\//,$_->[1])[2,0,1]] } @a; close FD;