diff options
-rwxr-xr-x | .local/bin/sentences | 18 |
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 | ||
3 | use strict; | 3 | use strict; |
4 | my $pont=qr{[.!?]+}; ## pontuation | ||
5 | my $abrev=qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abreviations | ||
6 | 4 | ||
7 | $/=""; | 5 | my $pont = qr{[.!?]+}; ## punctuation |
6 | my $abrev = qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abbreviations | ||
8 | 7 | ||
9 | while(<>){ chomp; ## for each paragraph, | 8 | $/ = ""; |
10 | 9 | ||
11 | s/\h*\n\h*/ /g; ## remove \n | 10 | while(<>) { |
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 | } |