in reply to Out of memory Error

Aside from the obvious fact that loading a 72MB file into a hash will take up more than 72MB, trying to sort that hash is also going to take up a lot of memory. Just glancing through Perlguts Illustrated suggests that an undef scalar will probably be at least 12 bytes: 4 for the pointer, 4 for the reference count, 3 for the flags and 1 (?) for the type. Note that this does not even account for the actual data being stored! All of this gives Perl tremendous flexibility, but it's not terribly memory efficient.

I don't think this is a bug in Perl. You're just chewing up a lot of memory (and your machine's specs will also play a large part in this). I think you should check out a merge sort. The File::Sort module should handle this for you.

Cheers,
Ovid

Note: Weird coincidence: I was updating this with some data from Perlguts Illustrated before I saw Abigail-II's response. Go vote for that node. Much better info than mine.

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.