blob: 75314f5c6c7d9ca48b56362f32c69755710be7cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/usr/bin/perl
use strict;
my $pont = qr{[.!?]+}; ## punctuation
my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations
$/ = "";
while(<>) {
chomp; ## for each paragraph,
s/\h*\n\h*/ /g; ## remove \n
s/($pont)\h+(\S)/$1\n$2/g; ## punctuation+space
s/($abrev)\n/$1 /g; ## undo \n after abbreviations
print "$_\n";
}
|