Yes, I think we both understood that requirement, and both suggestions can be used to do what you want. If you are familiar with looping through
perl arrays using subscripts: $array[n] then using Tie::File will be pretty straight forward once you read the documentation.
S_M's suggestion reads the file in chunks, not line by line, and looks like it should work although the last match might fail if there isn't two newlines at the end of the file. You will have to try it and see or maybe he can clear that up.