Kent's Perl Programs for Data Tasks
The following programs are tools I've written and reused over the years--some by only me, some shared among coworkers. They're not polished software, but they work the way I need them to. I'm sharing them 'as-is' with no guarantees. Feel free to 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 fine on Windows and Mac OS X, too, if you have Perl available (such as Strawberry Perl for Windows; Mac OS X has perl installed already). Perl version 5 is assumed unless otherwise noted.
- Compute frequency counts for alphanumeric values in a column range. Answers the question "how many times do the unique values in columns x through y occur in this file?".
- Frequency counts w/percentages adds percentages & cumulative percentages to the frequency count program above. This output is more like what SPSS frequencies produces.
- 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.
- 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.
- Report length of double-quoted and single-quoted strings in a text file (such as SPSS or SAS variable labels). New version.
- 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.
- Split a multi-column SAS input or SPSS data list statement into a single column. Useful for reformatting another way.
- Wrap a single column of SAS input or SPSS data list statements into multiple (5) columns. Fits more statements on a line.
- 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.
- 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.
- 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. For places with no trailing blanks as a rule for programming, this program will tell you if you need to fix anything in your files.
- Detab a file, two different methods Detabbing in this context means replacing tabs with spaces in a file. The two methods are column-based and literal replacement of tabs by a certain number of spaces.
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 geared toward the beginning Perl programmer. This site has advice on what books to read, common 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 Aug 31 20:47:26 EDT 2025
(What happens when AI tries to write your web content. I don't talk like this.)