Now that your basic problem is solved, I'm wondering: whose idea was it to invent this file format, and why was it made to be just sort of like -- but significantly different from -- XML?

If the tagging for the data structure went like this, it would qualify as valid XML:

<rec id=4> varFoo = bar some text some text ... </rec>
Not only would you have the option of using some very handy and powerful XML modules and tools on the data, but you would also find it easy to do "one-liner" stuff using the constant-string close tag as the input record separator -- e.g.:
# command line perl script to put all "var2 = 3" chunks into a separat +e file: perl -ne 'BEGIN{ $/="</rec>\n" } print if /var2 = 3/' input > var2_3.o +utput # just do the opposite (change "if" to "unless") to save the other chu +nks elsewhere
As it is, with a space in every close tag, and all close tags being different, your data is not XML, and it's a pain in the neck.

In reply to Re: help: extracting multiple lines from file based on match in one line by graff
in thread help: extracting multiple lines from file based on match in one line by my_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.