in reply to Sort large files

Hmm. You are slurping the entire file?
my @infile = <>; # Reads file

And you sort only by 17 resp. 2 bytes?

### Define the sort key here ### # Sorts in ascending order. sub key1 { ( substr( $a, 3, 17 )) cmp ( substr( $b, 3, 17 )); } # Sorts descending order. sub key2 { ( substr( $b, 20, 2 )) cmp ( substr( $a, 20, 2 )); } #

doing two substr() calls for each comparison? Heck, that's inefficient. You could calculate the comparison data for each record once, use that as key and store the records in a DB_File of type DB_BTREE. Then you iterate over that DB_BTREE hash with each, output the value for each tuple - and voilà - you get your records in sorted order. Memory requirements should be minimal, and DB_File is pretty fast.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}