aaron_baugher++ has solved the problem. But as to the regex, why reinvent the wheel when has modules to identify English sentences? For example, Lingua::EN::Sentence contains a get_sentences function which seems to do nicely:

#! perl use strict; use warnings; use Lingua::EN::Sentence 'get_sentences'; local $/ = ''; # Paragraph mode my $sentence_count = 0; my $paragraph_count = 0; my @paragraphs; while (my $paragraph = <DATA>) { my $sentences = get_sentences($paragraph); @$sentences = map { '<s>' . $_ . '</s>' } @$sentences; push @paragraphs, "<p>\n\t" . join("\n\t", @$sentences) . "\n</p>\ +n"; $sentence_count += scalar @$sentences; ++$paragraph_count; } print "\nTotal sentences: $sentence_count\n"; print "Total paragraphs: $paragraph_count\n"; print for @paragraphs; __DATA__ But the truth is that in the short run, markets can occasionally be pu +shed, especially when so many decisions to buy or sell are keyed off +what everyone else in the market is doing. Chain reactions are not mu +ch harder to start (in fact, given how quickly price moves get notice +d, they may be easier) than they were 70 years ago. This is a sentence containing ... an ellipsis. "Well, OK then," he sai +d, "but let's not get ahead of ourselves." And so to bed... And in this sentence, dialogue is delimited with single quotes. 'Well, + OK then,' he said, 'but let's not get ahead of ourselves.' And the h +euristic still works!

Output:

12:59 >perl 741a_SoPW.pl Total sentences: 8 Total paragraphs: 3 <p> <s>But the truth is that in the short run, markets can occasio +nally be pushed, especially when so many decisions to buy or sell are + keyed off what every one else in the market is doing.</s> <s>Chain reactions are not much harder to start (in fact, give +n how quickly price moves get noticed, they may be easier) than they +were 70 years ago.</s> </p> <p> <s>This is a sentence containing ... an ellipsis.</s> <s>"Well, OK then," he said, "but let's not get ahead of ourse +lves."</s> <s>And so to bed...</s> </p> <p> <s>And in this sentence, dialogue is delimited with single quo +tes.</s> <s>'Well, OK then,' he said, 'but let's not get ahead of ourse +lves.'</s> <s>And the heuristic still works!</s> </p> 12:59 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re^5: How to match regex over multiline file by Athanasius
in thread How to match regex over multiline file by kyaloupe

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.