950 Mb for a 50 Mb is a lot of memory, even for Perl.
How are you storing your file? As an array of characters?
Then the memory consumption is no surprise. But if you
store the file as a single string, you should consume about
50 Mb of memory.
in reply to Out Of Memory error at 950MB with 14GB free RAM
I'd first try to find out what is causing the memory consumption. It might not even be related to your input.
Something of the form $a [] = 1; could
cause the out of memory problem as well.