]> git.donarmstrong.com Git - perltidy.git/commitdiff
utility to check for minor problems with text
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 7 Dec 2024 23:44:21 +0000 (15:44 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 7 Dec 2024 23:44:21 +0000 (15:44 -0800)
dev-bin/check_text.pl [new file with mode: 0755]

diff --git a/dev-bin/check_text.pl b/dev-bin/check_text.pl
new file mode 100755 (executable)
index 0000000..c3622a5
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/perl -w
+use strict;
+
+# Perform some basic checks on text:
+#  - report lines with lengths > 80
+#  - report any tabs
+#  - report lines with ending spaces
+my $too_long;
+my $has_tab;
+my $has_ending_space;
+my $lno = 0;
+#while ( my $line = <$fh> ) {
+while ( my $line = <> ) {
+    $lno++;
+    chomp $line;
+    my $excess = length($line) - 80;
+    if ( $excess > 0 && $line =~ /^\s/ ) {
+        print "$lno:x=$excess:$line\n";
+        $too_long++;
+    }
+    if ( $line =~ /\t/ ) {
+        print "$lno:tabs:$line\n";
+        $has_tab++;
+    }
+    if ( $line =~ /\s+$/ ) {
+        print "$lno:end spaces:$line\n";
+        $has_ending_space++;
+    }
+}
+if ($too_long) {
+    print "$too_long lines exceed 80 chars:\n";
+}
+if ($has_tab) {
+    print "$has_tab lines contain tabs:\n";
+}
+if ($has_ending_space) {
+    print "$has_ending_space lines end in a space:\n";
+}