in reply to Finding first block of contiguous elements in an array
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Finding first block of contiguous elements in an array
by BrowserUk (Patriarch) on Dec 21, 2002 at 16:36 UTC |