in reply to How to split into paragraphs?

Try setting $/ = '';.

#! perl -slw use strict; $/ = ''; # paragraph mode print "'$_'" while <DATA>; __DATA__ abc: asdf1 asdf2 def: asdf3 ghi: asdf4 asdf5

Prints

c:\test>junk 'abc: asdf1 asdf2 ' 'def: asdf3 ' 'ghi: asdf4 asdf5 '

Setting $/ = "\n\n"; would also work for your data if there is exactly one 'blank line' between the paragraphs, but the magical setting of $/ = ''; is more flexible.

Note this quote from perlvar

Setting it to "\n\n" means something slightly different than setting to "", if the file contains consecutive empty lines. Setting to "" will treat two or more consecutive empty lines as a single empty line. Setting to "\n\n" will blindly assume that the next input character belongs to the next paragraph, even if it's a newline.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: How to split into paragraphs?
by jrw (Monk) on Nov 16, 2006 at 12:27 UTC
    BrowserUk, see clarification above. I already have the entire string in a variable.

      This works.

      print "'$_'" for split m[(?=^\w+?:)]sm, $data;

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.