in reply to Re: regexp over multiple lines
in thread regexp over multiple lines

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 :-)

Replies are listed 'Best First'.
Re^3: regexp over multiple lines
by Sinistral (Monsignor) on Aug 03, 2011 at 13:33 UTC

    The monks have been helping you solve the individual problem that you've defined, but missed the very important point you made here - that your files are XML. Using an XML parser, whether XML::Twig, XML::Simple, XML::LibXML, or something else, is THE way to process XML files (and to head off the argument: Yes, even you can use CPAN). Trying to do so via regular expressions is simply madness. You're recreating tools that have already been created and debugged and replacing them with half baked code that will no doubt miss many edge cases.