in reply to Re: Far across cyberspace
in thread Editing a text file without reading it into an array

Careful. foreach expands the bracketed list first so you still slurp the file. You only sidestep the declaration of a temporary array variable. Your code will however work exactly as intended - without the need for any other modifications - if you simply substitute foreach for while.

Makeshifts last the longest.