in reply to open file for read/write

You might be intersted in Tie::File, which treats a file as an array. Any changes to the array translates to changes in the file.