in reply to Using punctuation to split a text
use strict; use warnings; my $rxBoundary = qr {(?xms) (?: (?<=[a-z])(?=[A-Z]) | (?<=[.!?])(?=\s?[A-Za-z]) ) }; my $text = <DATA>; chomp $text; print map {qq{$_\n\n}} split m{$rxBoundary}, $text; __END__ The Tell-Tale HeartEdgar Allen PoeTRUE! nervous, very, very dreadfully + nervous I had been and am; but why WILL you say that I am mad? The d +isease had sharpened my senses, not destroyed, not dulled them. Above + all was the sense of hearing acute. I heard all things in the heaven + and in the earth. I heard many things in hell. How then am I mad? He +arken! and observe how healthily, how calmly, I can tell you the whol +e story.
and the output is
The Tell-Tale Heart Edgar Allen Poe TRUE! nervous, very, very dreadfully nervous I had been and am; but why WIL +L you say that I am mad? The disease had sharpened my senses, not destroyed, not dulled them. Above all was the sense of hearing acute. I heard all things in the heaven and in the earth. I heard many things in hell. How then am I mad? Hearken! and observe how healthily, how calmly, I can tell you the whole story +.
I hope this is of use.
Cheers,
JohnGG
|
|---|