It's not clear if the only thing you want is the first occurence of TITLE, but assuming it is, the simplest thing to do is to just stop processing your input stream once you are done with first set of title lines. And if you want to avoid "flag" vaiables, you can allways use a nested loop over the input handle.

something like this (psuedo-perl) perhaps...

while (<STDIN>) { next unless /^TITLE\s+(.*)$/; my $title = $1; while (<STDIN>) { last unless /^TITLE\s+\d+\s+(.*)$/; $title .= $1 } print "Here is the title you wanted: $title"; last; }


In reply to Re: Finding first block of contiguous elements in an array by hossman
in thread Finding first block of contiguous elements in an array by FamousLongAgo

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