summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.local/bin/sentences18
1 files changed, 10 insertions, 8 deletions
diff --git a/.local/bin/sentences b/.local/bin/sentences
index a02d061..75314f5 100755
--- a/.local/bin/sentences
+++ b/.local/bin/sentences
@@ -1,16 +1,18 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2 2
3use strict; 3use strict;
4my $pont=qr{[.!?]+}; ## pontuation
5my $abrev=qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abreviations
6 4
7$/=""; 5my $pont = qr{[.!?]+}; ## punctuation
6my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations
8 7
9while(<>){ chomp; ## for each paragraph, 8$/ = "";
10 9
11 s/\h*\n\h*/ /g; ## remove \n 10while(<>) {
12 s/($pont)\h+(\S)/$1\n$2/g; ## pontuation+space 11 chomp; ## for each paragraph,
13 s/($abrev)\n/$1 /g; ## undo \n after abreviations
14 12
15 print "$_\n\n"; 13 s/\h*\n\h*/ /g; ## remove \n
14 s/($pont)\h+(\S)/$1\n$2/g; ## punctuation+space
15 s/($abrev)\n/$1 /g; ## undo \n after abbreviations
16
17 print "$_\n";
16} 18}