![]() ![]() ![]() ![]() |
Wicked Cool Perl Scripts
by Steve Oualline
No Starch Press, 2005
ISBN 1-59327-062-3
Reviewed by Peter Scott (2006)
I have been reading Steve Oualline's columns on C and shell programming for many years now, and this is his second book on Perl.The format of this book is 47 scripts organized into 11 chapters on the following topics: general purpose, website management, CGI debugging, CGI programs, internet data mining, Unix system administration (see if you don't think "BOFH" while reading this chapter), picture utilities, games, development tools, mapping, and a regular expression grapher.
Steve has a very chatty writing style that pulls you into the book and his stories about his family; no surprise if you've met him, since you'd know how nice a guy he is. He's good at combining scripts and got me thinking about some of the things I could do to automate some security operations. This book will be useful to system administrators with intermediate or less Perl expertise, and to web developers and general programmers who have just begun programming Perl.
Many of these scripts are quite useful, and there's nothing wrong with the code, which is very easy to understand. The problem that you may have is with the provocative title, which begs you to hold the contents to whatever your standard of "wicked cool" is. Personally, when I think "wicked cool Perl scripts," I think first of SelfGOL and the Obfuscated Perl Contest winners. So I found most of these scripts rather pedestrian. The Unix administration scripts solve real problems but aren't as portable as I'd like (does "nm" really output the same format on every platform?) and the sort of industrial strength features you'd want in high-pressure operational environments are often left as suggestions for the reader.
There's no denying the utility of programs like a disk space alarm or a photo gallery, but I had a strange feeling of being transported back in time to the scripts in the first (pink) edition of "Programming Perl" (the Camel). Of course, these programs are written in Perl 5, not Perl 4, and they follow good practices such as "use strict" and "use warnings" in every file.
Some of the other practices suggest that Steve hasn't made the transition from C to Perl fully, though. He defines subroutines before the main code, prefers concatenation to interpolation, tests array sizes using $#array + 1 instead of @array in scalar context, and almost never uses postfixed control statements or or and and for control flow. In one case he uses the POSIXC asctime() function to get a stringified date from localtime() that he then has to chomp() instead of simply using localtime() in scalar context. The scripts are generally longer than they need to be because a lack of common idioms such as the Orcish maneuver.
The scripts are very well commented and Steve uses a very good (and labor-intensive) way of annotating regular expressions with ASCII art. Speaking of which, the final chapter certainly does qualify as wicked cool, as it generates graphs of regular expressions. The mapping programs can generate a map from USGS data of any given area and have unfortunately been almost completely overshadowed by GoogleEarth, but if you're using a machine that doesn't run Google Earth then you may well find them both wicked cool and genuinely useful.
This review was first published in "The Perl Review", Volume 3, Issue 2.
© Pacific Systems Design Technologies
Revised