in reply to redo entire loop

You could try Tie::File and iterate through each line looking for your desired value/data and modify it directly. If I understood the documentation correctly, Tie::File does not necessarily store the entire file in memory and allows for the user to control it's memory usage setting when called.

Replies are listed 'Best First'.
Re^2: redo entire loop
by ikegami (Patriarch) on Aug 13, 2010 at 16:01 UTC
    A Tie::File solution would look like the following, but it would be much more expensive than the following:
    my $found = 0; while (<$fh>) { if (match()) { $found = $.; last; } } if ($found) { seek($fh, $found, SEEK_SET); open(my $fh_tmp, '<', ...) or die; while (<$fh>) { transform(); print $fh_tmp $_; } replace_original_with_tmp(); }