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

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; }

Replies are listed 'Best First'.
Re^4: Help needed in reading a very large file line by line
by choroba (Cardinal) on Dec 01, 2014 at 17:29 UTC
    Can you
    print "$.: $line"
    and check at what line it fails?
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ