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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing a string into "paragraphs"
by jrw (Monk) on Nov 28, 2006 at 01:54 UTC |