From 1c50f2ee41a5ece26cde93e9f5cf5b1036714651 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 17 Jan 2021 15:56:15 +0300 Subject: tidy up sentences script --- .local/bin/sentences | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to '.local/bin/sentences') 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 @@ #!/usr/bin/perl use strict; -my $pont=qr{[.!?]+}; ## pontuation -my $abrev=qr{\b(?:Pr|Dr|Mr|[A-Z])\.}; ## abreviations -$/=""; +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; ## pontuation+space - s/($abrev)\n/$1 /g; ## undo \n after abreviations +while(<>) { + chomp; ## for each paragraph, - print "$_\n\n"; + 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"; } -- cgit v1.2.3-70-g09d2