The obvious part of your question refers to return all matches from a regex match.
That can easily done like this (I simplified your regex, as the missing parenthesis makes it unclear, what you really want):
while(<STDIN>)
{
# see previous answer
#undef ($/);
$string=$_;
my @matches = ($string =~ m/(FINDINGS|COMPLICATIONS|:.*)/g);
print STDOUT "@matches \n";
}
echo "FINDINGS COMPLICATIONS :something" | t.pl
However from your question it seems, what you really want is not just to get a list of matches, but some sort of parsing. eg. extract the text from the section "FINDINGS" etc.
To answer this, it would be necessary to know, where a section ends. If this is not, what you wanted, please clarify.
|