in reply to Editing a text file without reading it into an array
You can try using Tie::File, which will try as much as possible not to read the entire file into an array, while letting you use it as an array of lines.