qscan.pl -- Scan for Excessively Long Quoted Strings (new version)
Like 40scan.pl, this program scans a text file or program for double-quoted strings, but adds scanning for single-quoted strings. If found, it reports those which are longer than a defined number of characters. The default is 40 characters, but qscan lets you define other string lengths to search for on the command line. Originally written to ensure SAS and SPSS variable labels were within the length limitations of the language. qscan can be used for checking a variety of quoted string lengths. Get all labels fixed without rerunning SAS repeatedly!
- 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.
- Very long lines will be truncated in the output. This is to keep the output from getting too wide. The length will still be reported.
- The program looks for double-quoted and single-quoted strings.
- The variable $checklen in the program sets the default length of strings to search for.
- Useful for making sure all your labels are within length limits, including SAS, SPSS limits, or for in-house standards.
- qscan will not report quoted strings that are split across multiple lines. The program was written for SAS and SPSS value and variable label checking not general text. Keep the label for a variable or value on a single line.
- Show qscan.pl code
- Download: qscan.pl
Usage
Assuming this program is executable, its commandline is: qscan [-l#] [filename...]
where:
- -l# is the number of characters within quotes to search for
- filename is the text file to be processed
An example run is shown below.
> qscan test.txt Page 1 qscan: Find long quoted text by Kent Nassen, v1.9, 9/16/25 Scanning for quoted text longer than 40 characters in the file testulc.txt Quote Line# Length Line Contents/*** Message ------- -------- ---------------------------------------------------------- 4 42 v4 "This is a longer label for the variable v4" 5 61 v5 "This is a very long label for the fourth variable w... 6 70 v6 'This is a single-quoted label for the fifth variabl... There were 8 lines in 'testulc.txt' 3 lines had quoted text over 40 characters long. The length of the longest quoted text found was 70 characters at line 6.
Back to Kent's Perl Page
Last Modified: Sun Sep 28 16:16:59 EDT 2025