in reply to Massive Sorting

(party line) Why don't you try adding use strict; and possibly use warnings. Using local variables might significantly decrease your ram usage (then again, it might not)