Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Finding first block of contiguous elements in an array

by Arien (Pilgrim)
on Dec 21, 2002 at 16:29 UTC ( [id://221640]=note: print w/replies, xml ) Need Help??


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

    'cept that that will bottle out too early unless the first line is a title line (which it isn't)?

    Update: Talking That which begins with B and ends in ollocks again. Arien++


    Examine what is said, not who speaks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://221640]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2025-01-13 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (28 votes). Check out past polls.