If I understand your question right, something like this may do what you want:

$your_data =~ /\+Header1(.|\n+)-Header1\n\+Header2(.|\n+)-Header2\n\+H +eader3(.|\n+)-Header3\n/;

I wouldn't suggest using that as anything but a starting point, though. There are regex options for changing the . operator to match \n's, and you may want to consider doing a line by line parse (and having boolean--i.e., flag--variables to tell you what section you're in).

The last suggestion might be started like this:

while ($line = <your_file_handle>) { if($line =~ /^\+Header1/) { $header1 = 1; next } # if +Header1 has its own line use next elsif($line =~ /^-Header1/) { next } else { $header1 = 0 } . . . if($header1) { $h1_data[$index++] = $line; } . . . }

Again, these are just quick things to get you started thinking; you may want to look at this site and search for regex, or look at the perlman pages for more information regarding them.


In reply to Re: Text file filtering by dimmesdale
in thread Text file filtering by surfmonkey

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.