40scan.pl -- Scan for Excessively Long Quoted Strings
This Perl program to reads through a text file looking for double quoted strings and reports those which are longer than a defined number of characters (default=40). The output consists of the line number of the long quote, the length of the quoted text, the actual line containing the quoted text, and at the end of the run a summary of the number of lines with excessive length, the number of lines in the file, and the location and length of the longest quote.
- This program is intended to be run from a Unix or Linux command line.
- Output is sent to STDOUT, so redirect it to a file to save the output.
- The program only looks for double-quoted strings.
- The variable $checklen in the program sets the length of strings to search for.
- Useful for making sure all your labels are within length limits, including SAS, SPSS, or in-house standards.
- Show 40scan.pl code
- Download: 40scan.pl
Usage
Assuming this program is executable, its commandline is: 40scan.pl infile
where:
- infile is the text file to be processed
An example run is shown below.
~> 40scan.pl test.txt Page 1 40scan: Find quotes longer than 40 characters by Kent Nassen, v1.5, 9/22/98 Scanning for long quoted text in the file: test.txt Line# Length Line Contents ------- -------- -------------------------------------------------------------- 7 42 v3 "This is a longer label for the variable v3" 8 61 v4 "This is a very long label for the fourth variable which is v4" 2 lines had quoted text over 40 characters long. There were 8 lines in the file. The length of the longest quoted text found was 61 characters at line 8.Remaining to do are allowing the user to select the width to scan for on the command line and scanning for single-quoted strings.
Back to Kent's Perl Page
Last Modified: Tue Jul 15 13:42:04 EDT 2025