Can anyone think of an elegant way to grab the first block of 1+ contiguous TITLE lines, and stop?
my $title; for (@data) { if (/^TITLE\s+\d*(.*)/) { $title .= $1; } else { last if defined $title; } }
The elegance would be in not adding a flag but rather reusing $title for that purpose (since it already contains the state the flag would save).
— Arien
In reply to Re: Finding first block of contiguous elements in an array
by Arien
in thread Finding first block of contiguous elements in an array
by FamousLongAgo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |