It is giving "Out of memory" because in your environment (I suppose it is a UNIX based one) your settings for "ulimit -a" at "data(kbytes)" is less than the file's size; Try modifying the data parameter with a value larger than the file you are processing.
If you can't do that, use Tie::File. Slower but not a memory hog user.