in reply to Sorting files

Usually what you can do is to sort as many files as you can in memory and write those temporary files to disk. Merging sorted lists is something that can be done in constant memory by reading a line from each file and then writing the smallest line of these into a new file, refilling from the file.

There also are Sort::Merge and Sort::External I believe.