Hi, I am new to Perl and trying to figure out how I can select a block of text and extract some data out of it. All blocks are the same; they are \n\n apart from each other and start with string "Processing..." I want to extract what comes after "Processing.....:", tab what comes after "Phrase:" tab, what comes underneath of "Meta Mapping (some digit)", if there are more than one phrase, same process happens and "Process..:" data being repeated for all phrases until it reaches \n\n. So, for the block below I should get two rows, in the first column "Mental status change over the last 5 days" being repeated in row 1 and 2, the "phrase:" results appear in column 2, and the line below "meta mapping" appears in the third column (which is "none" for the second row. The loop should jump to the next block until the end of the file. "meta candidate" results can be ignored. I'd appreciate any help/hint

Processing 00000000.tx.2: Mental status change over the last 5 days.
Phrase: "Mental status change"
Meta Mapping (1000)
1000 D0072276:MENTAL STATUS CHANGE (ALTERED MENTAL STATUS) (Mental or Behavioral Dysfunction)

Phrase: "over the last 5 days."
Meta Candidates (0): <none>
Meta Mappings: <none>


Processing 00000000.tx.1:........

output
Mental status change over the last 5 days (tab) Mental status change (tab) 1000 D0072276:MENTAL .......
Mental status change over the last 5 days (tab) over the last 5 days (tab) none

In reply to block extraction by zzgulu

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.