in reply to Pattern search in a Multiline Record, from a multi-record datafile.

Depending on how big the file is and how XML compliant it is, you might also want to use one of the XML handling modules like XML::Simple, or XML::LibXML. They can simplfy things so you don't have to write a bunch of regex's to handle the different tags. Some of them are also designed to handle huge files reasonably efficiently

edit:
realized you aren't rewriting so removed that comment

If it's not XML compliant, the XML parsers might fail on you (they're supposed to), but something like HTML::TreeBuilder or HTML::TokeParser might also be convenient. I've used both for what I think is a similar task, and they're pretty straightforward.

more edit
The XML modules or HTML::TreeBuilder will parse things and maintain all the structure that you're otherwise trying to reconstruct out of the array elements, as BrowserUK suggests.

  • Comment on Re: Pattern search in a Multiline Record, from a multi-record datafile.