I appreciate all the great feedback. I am very new at Perl and therefore, very green. I am learning as I go and your response has helped me a lot.
I did in the end go with a modified version of John's code. It was very close to what I wanted in the end and was easy enough for me to modify to do exactly what I wanted.