in reply to using lookaround assertions to grab info

Perhaps you want to split on /\n\b/. That will require new records to begin with a word char (because \n is not a word char).

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re^2: using lookaround assertions to grab info
by punkish (Priest) on Jun 03, 2004 at 21:49 UTC
    Perhaps you want to split on /\n\b/. That will require new records to begin with a word char (because \n is not a word char).
    I am not sure how this helps me. In the example I have provided above, I have added the newlines. In reality, the email message is provided to me as a scalar, with all the newlines and all in it already. I just use Mail::IMAPClient to grab the message.

    As I said, the code I have above works fine even with splitting on newlines. Where it fails is its inability to "lookbehind" when it encounters a line without a label -- something that looks like so --

    : sometext
    I believe that when I encounter a line like above, I have to lookbehind and say, "Ha, this line doesn't begin with a label, hence it is just a continuation of the value of the previous label."

    This is where I am lost.

      In reality, the email message is provided to me as a scalar, with all the newlines and all in it already.
      And you want to split on those newlines, except where the next line doesn't begin with a letter. You want those lines that don't begin with a letter not to be split from the previous lines.

      Maybe you should just try it and see what you get.


      The PerlMonk tr/// Advocate
        And you want to split on those newlines, except where the next line doesn't begin with a letter. You want those lines that don't begin with a letter not to be split from the previous lines. Maybe you should just try it and see what you get.
        I tried. And... Sweet. This works just swell. I wish I could vote more than once for your tip for what I learned from it.

        Many thanks.