in reply to Speed differences in updating a data file

For large files, you're certainly going to benefit from not keeping vast amounts of data in memory. You're going to improve in terms of memory allocation overhead, how efficiently your processor's cache is used, and generally reduced machine load (from having less to manage in virtual memory), I would think.

So I'd expect that once your file passes a certain mystery size threshold, your first approach will be much faster.

If you don't need the other lines, why keep them around? Of course, for a small file, it's hard to beat the ease of typing

my @lines=<FILE>;
If your problem requires multiple passes over the data, or transformations across all the lines, then you may not have a choice but to keep it all in memory, though. An example of that would be a matrix transposition, for instance.
--
Mike