Matt's Perl Page
Welcome to my Perl page. Here are some goodies related to the Perl programming language.

Order Unix Unleashed Here

I wrote the CGI Programming in Perl chapter and some other CGI-related stuff for Unix Unleashed, Internet Edition, published by SAMS. (Please don't hold that against me.) Given that the amount of time most authors have to produce technical books these days is about a third of what it ought to be, errors tend to find their way to print. If you find any errors in anything with my name attached to it, please let me know so I can make note of corrections here.

Why Perl?
Perl is a wonderfully powerful language that is particularly well suited to writing tools for the Internet. Its portability, flexibility, speed, and powerful text processing capabilities make it ideal for many tasks which are very difficult to do in other languages.

I hear you already... ``Didn't you write an essay about how great and wonderful Java is?'' In fact, yes I did. Java and Perl are two different programming languages, with very different views of the world. The result is that some problems are better solved in Java, while others are better solved in Perl. Use the right tool for the job. (And, truth be told, the point of my essay was more about the importance of a single, unified Java Virtual Machine (JVM) than about the Java programming language. I'm rather looking forward to having my Perl programs run on any platform where the JVM can be found, without modification, without recompilation, and without a headache.)

Here are some Perl programs that might be of interest. Hopefully, you'll find something here that demonstrates something you're interested in, and you can see how to do it safely.

Most of these are CGI programs, though I'm sure I'll park lots of other stuff here in the future. Obligatory warning (that you shouldn't ignore): Remember, CGI scripts are programs that an untrusted user invokes on your system. Bad people will try to trick it into doing bad things. Remember to think about the security of what you're doing, not just the functionality!

crfingerd is a Perl replacement for your system's finger daemon. It was written so that local users whose directories were part of a chroot(2)'d could work with the finger service. This works by accepting the account to be finger'd on STDIN (from the socket) and performing a lookup. If the user is local, finger is run against the account and the result returned. If the user is chroot'd, a wrapper that will run the finger properly is invoked. If the user is not chroot'd, normal finger will be run. If the user does not exist, an error is returned. You can install this by saving the file (with correct permissions, i.e., read and execute) in /usr/local/sbin/crfingerd and then replacing the finger line in /etc/inetd.conf with this:
finger  stream  tcp  nowait  nobody   /usr/local/sbin/crfingerd   cfingerd
Then send a SIGHUP to the inetd process, and you're on your way.
httpd-p takes a list of web sites from a file, queries them all, figures out which server each runs, and then reports aggregate statistics, each type of web server found, and how many of each. Maybe in the future, I'll make a webified version of this so you can try it right online. But for the time being, you'll have to download it, unwind it, and use it. A Makefile is included for your convenience in testing, installation, and making documentation.

This is a simple web front-end to the Unix dig command. It demonstrates the following: Try it or view the source!

A tiny CGI program that shows all of the environment variables names and values. This can be useful if you're interested in what sorts of things your HTTP dæmon is showing to your programs. Try it or view the source.

Here's a fun way to evaluate the strength of that crypto product you're considering. This one is a little more complex. When you request the page, it looks to see whether you're submitting information to it, or whether you're doing a plain ol' GET. If you're doing former, you'll have your answers processed; if you do the latter, you'll be presented the fill-out form. Try it or, if you prefer, view the source and the comments therein.
Here's a way to maintain your own web link exchange service. Rather than rely on everyone to include a link back to a server you don't control, and hope that they have the right numbers in their HTML to identify which sites are previous and next, just have everyone in your ring point to this program, running on your own server. Try it to get a random link on this site, or view the source. Also, you might be interested in looking at the database of URLs that the program uses. This also is an example of how to use the excellent perldoc utility to create inline documentation.

interhack | cmcurtin | vitals | the soap box | publications | perl | hackcam | links

Matt Curtin
Last modified: Tue Feb 2 23:30:34 EST 1999