in reply to Inserting text into the middle of a file without clobbering any other text
Tie::File will do what it sounds like you want.