Hello Monks,

I am attempting to do the classic match across mulitple lines (with a small twist) that I can't seem to figure out.
The file is set up as such.
Header1
A list of numbers (1-50)
END LIST
Header1
A different list of numbers (1-50)
END LIST
Header2
A diffierent list of numbers (1-50)
END LIST
The header text is the same but the subsequent # is different. Also, the list of numbers is variable (there could be 1-50).
What I wish to do is remove the header text line that only has the number 1 associated with it as well the list of numbers that follow it to the 'END LIST' line. If the header text line has any other number associated with it, print it out and the list of numbers associated with it to the 'END LIST'.

The code I have is not working...I am actually embrassed to post it. I have no! idea how to proceed and have looked around for ideas but to no avail.

my $text = do { local $/; <FILE> }; if ($text =~ /^Header1.*?END LIST/m) { .... }

Any help would be greatly appreciated.
Thanks,

Dr.J


In reply to match and remove across multiple lines by dr_jgbn

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.