Thanks for the reply :-)
I'm a novice in Perl so I went about this in a very different way! Instead of using an XML parser (which I wasn't aware of), I processed each XML file by replacing each ">" with ">\n" so that I ended up with a file with multiple lines instead of everything on just one line.
Since my program has to parse data from XML files and normal HTML files, I would like to avoid using an XML parser because my code is set up the wrong way.
I'm going to have to read your advice a few more times because it doesn't immediately make sense to me. I'll try a few tests in my program to see if I can get things working and increase my understanding.
I'll post back here for further help :-)