in reply to Parsing a string into "paragraphs"

And why would you slurp-and-split instead of processing the file sequentially? Something along the lines of:

my $c_para = ''; while (<$INPUT_FH>) { $c_para.=$_; if ( /$end_of_para_pattern/ ) { process_paragraph($c_para); $c_para = ''; # we'll start a new paragraph next pass } }

has always worked for me. If you really needed an array of paragraphs, you could always push them onto an array instead of calling process_paragraph...

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

Replies are listed 'Best First'.
Re^2: Parsing a string into "paragraphs"
by jrw (Monk) on Nov 28, 2006 at 01:54 UTC
    Slurp and split is substantially more readable, IMHO.