summaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
authorYigit Sever2021-01-17 15:56:15 +0300
committerYigit Sever2021-01-17 15:56:15 +0300
commit1c50f2ee41a5ece26cde93e9f5cf5b1036714651 (patch)
treed7cf02d642b5b46773af25cce2ca3ab2b5ca06fa /.local
parent900d60db7fbef32a952b65f2daf262a5aa8a24ba (diff)
downloaddotfiles-1c50f2ee41a5ece26cde93e9f5cf5b1036714651.tar.gz
dotfiles-1c50f2ee41a5ece26cde93e9f5cf5b1036714651.tar.bz2
dotfiles-1c50f2ee41a5ece26cde93e9f5cf5b1036714651.zip
tidy up sentences script
diffstat (limited to '.local')
-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}