There are several ways to handle this. Without seeing your code, I can only guess at what you've tried.

One approach is to read more than a line at a time. You could set $/ to read in a record at a time, which is made easier if there's a blank line or some other marker between records.

Another approach is to read the entire file into a scalar, by localizing $/ within a block, reading the file into a scalar, and then using multi-line regexes.

You could read the entire file into an array, loop through with an index variable, incrementing the index as necessary, or building up a second array of lines.

Similarly, you could loop through a line at a time, building a single array, appending a continued line.

Depending on how large the file is, you might want to continue processing a line at a time. I would probably do something like this pseudo-code:

# open file # declare a last_line variable # loop, reading a line at a time # check to see if line is continued # if so, append the current item to the last_line variable # set a flag that we've done this # process last_line (in another function, probably) # stick the current line in last_line # if the flag is set, empty out last_line
This depends on a lot of specifics, but you get to process (basically) a line at a time for the small overhead of keeping a little bit of state information around.

In reply to Re: Look ahead and comp if pattern matches next line by chromatic
in thread Look ahead and comp if pattern matches next line by Er1kW

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.