in reply to Re: Help needed in reading a very large file line by line
in thread Help needed in reading a very large file line by line

while(<FILEHANDLE>) is giving an out of memory error.
  • Comment on Re^2: Help needed in reading a very large file line by line

Replies are listed 'Best First'.
Re^3: Help needed in reading a very large file line by line
by jethro (Monsignor) on Feb 28, 2012 at 11:43 UTC

    Just post your script (between <c> </c> tags) and we can tell you what is wrong.

Re^3: Help needed in reading a very large file line by line
by tobyink (Canon) on Feb 28, 2012 at 13:26 UTC

    Chances are that either $/ is set to something silly instead of "\n", or your file has no line break characters in it (or at least, very long lines).

Re^3: Help needed in reading a very large file line by line
by Anonymous Monk on Feb 28, 2012 at 11:10 UTC
Re^3: Help needed in reading a very large file line by line
by MegART (Novice) on Dec 01, 2014 at 17:22 UTC

    Hi, I see this is an old thread, but still, I would like to share that I have expereciend something similar. I wanted to do a very simple search and replace on a huge ASCII file (around 4GB) using the magic filehandle <>. The thing is that I cannot use seek or whichever method that requires fixed length of records. Also my $/ is set to "\n" and I know that the lines are not incredibly long. Any ideas?

    Here is a piece of code:

    my $fh = new FileHandle; @ARGV = ($file); open $fh, ">test.txt"; while ($line = <>) { $line =~ s/$search/$replace/g; print $fh $line; }
      Can you
      print "$.: $line"
      and check at what line it fails?
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ