Kent's Perl Programs
The following programs are command-line tools I've written and reused over the years. I'm sharing them 'as-is' with no guarantees.You may copy, use, or modify them, as long as you leave my name in the code. All were developed on Unix systems (Solaris, FreeBSD), but they should run on Windows and Mac OS, too, if you have Perl available (such as Strawberry Perl for Windows; Mac OS has perl installed already). Perl version 5 is assumed unless otherwise noted.
These programs were written to work on raw ASCII text files such as LRECL (logical record length) data files where every line is the same length, or on program text files, etc. They are intended to be run from a command line. I used Perl because at the time, it was the best way that I had available to scan text files for patterns. It still is great for that although other languages have been developed that are more popular.
The only module I'm using is Getopt::Std, which is a Standard Perl core module. I made an effort to update these programs to use lexical file handles (though some use @ARGV processing so have no need of lexical file handles).
The links below go to pages that provide usage notes, example runs, assumptions of the programs as well as links to view the program code, and download the programs.
Many do simple text processing tasks and could be programmed in a language other than Perl.
- freq: Compute frequency counts for alphanumeric values in a column range of an ASCII LRECL data set. Answers the question "how many times do the unique values in columns x through y occur in this file?".
- freq2: Frequency counts w/percentages adds percentages & cumulative percentages to the frequency count program above. This output is more like what SPSS frequencies produces.
- fixblock: Block a stream data file to fixed line length by inserting newlines at a user-specified logical record length. Makes all the lines the same length from a stream of data.
- 40scan: Report length of double-quoted strings in a text file (such as SPSS or SAS variable labels). Used to keep commands within limits for strings.
- qscan: Report length of double-quoted and single-quoted strings in a text file (such as SPSS or SAS variable labels). New version. Generates a report of labels that are too long.
- today: Print a calendar with today's date highlighted Assumes VT100-compatible terminal emulation and an available Unix 'cal' command. Mostly no longer needed since several cal programs now have an option to highlight today's date.
- splitit: Convert multi-column SAS input or SPSS data list statements into a single column. Useful for reformatting SAS or SPSS input code another way.
- wrapit5: Wrap a single column of SAS input or SPSS data list statements into multiple (5) columns. Fits more statements on a line. splitit and wrapit5 do opposite formatting.
- cklg: Check a SAS log file for errors, warnings and other issues Output is in QuickFix format for use with the Vim editor.
- Using Vim's QuickFix functions, the output of this program supports jumping to the line of the error or warning in your SAS log. Or you can use the output directly to guide your debugging.
There is more SAS-related content on my Vim Functions for SAS Programming page. It includes a way to integrate cklg into gvim, as well as how to set gvim up for SAS development.
- deblank: Turn multiple blank lines into single blank lines. For example, if 3 blanks lines are found in a file, this program will remove 2 of them and leave one blank line.
- cktb: Check for trailing blanks at the end of lines.It reports the number of blanks (spaces or tabs) found on lines and the line with the longest string of blanks. If your programming standards say no trailing blanks, this program will tell you if you need to fix anything in your programs.
- detab: Detab a file, two different methods Detabbing in this context means replacing tabs with spaces. Choose between column-based alignment or literal replacement by a fixed number of spaces. Each method produces distinct output which can be selected based on formatting needs.
More About Perl
Here are some Perl web sites worth visiting if you are interested in learning about Perl, or need to find other Perl programs and tools.
- The Perl FAQ The Frequently Asked Questions file(s) for Perl (in HTML format). Very helpful!
- Perl for beginners: A Comprehensive Guide to Learning Perl Programming A page aimed at the beginning Perl programmer. This site has advice on what books to read, /ommon mistakes and problem solving, other Perl internet resources, and a Perl/CGI tutorial.
- Beginning Perl by Simon Cozens This is a free online book.
- Perl Language Home Page Includes Learning, Community, documentation, Events, and Perl Downloads.
- Perldoc Browser A ton of information, resources, sources, and links to perl-related stuff. Here you'll find information on CGI, regular expressions (regex), using perl for system & web administration tasks, date & time usage, text tools, Perl for Windows 3.1/95/NT, and much more.
- Comprehensive Perl Archive Network (CPAN) "...hundreds of Perl utilities, several books' worth of documentation, and the entire Perl distribution. If it's written in Perl, and it's helpful and free, it's in the CPAN." Perl modules can be found here, also.
- Meta CPAN A search engine for CPAN.
- Perl Mongers A non-profit organization whose mission is to establish Perl user groups.
Back to Kent's Home Page
Curated tools and programs by Kent Nassen. Unix-born, Perl-shaped, and field-tested.
Last Modified: Sun Nov 23 13:56:16 EST 2025
(This is what happens when an AI tries to write your web content. I don't talk like this.)
Back to Kent's Home Page