Many people are discovering that the scripting language Perl is the most useful language for getting many computing tasks done. In this article Dave Cross takes a brief look at some Perl books.
This article first appeared in the August 1999 issue of the online Perl magazine PerlMonth.
Note: All of the articles in the RTFM series are really old. It’s likely that many of the links no longer work. I’m leaving these articles online for historical reasons, but these days you should visit perl.org for links to the best current Perl resources.
Over the last three columns, I’ve been looking at the free documentation that you get with every copy of Perl. This month, I’d like to step back from that and take a brief survey of some non-free Perl documentation (i.e. Perl books). I’ll look at some of the best (and otherwise!) Perl books on the market and talk about what they cover. Hopefully, by the end of the article you’ll be dead keen to get over to Amazon to buy some.
I feel I should apologise that this column will read a bit like an advertisement for O’Reilly, but the fact is that they still publish the majority of the good Perl books. If any other publishers feel I have unfairly ignored their Perl books, then I’d be only to happy to have these oversights pointed out to me.
There are four books that I consider every Perl programmer should own. In the order that you will probably find them useful, they are:
Learning Perl (O’Reilly) ISBN: 1565922840
Randal L Schwartz & Tom Christiansen
Known to its friends as the Llama (because of its cover), this is the best tutorial for experienced programmers who want to learn Perl. Some people have complained that the first chapter’s ‘Stroll Through Perl’ covers too much too quickly, but they generally revise their opinion once they see that the rest of the book covers the same ground (and more) in much more detail.
The book covers a very useful subset of Perl which allows a reader to be producing useful Perl programs from very early in the book. There is even an introduction to CGI programming and an appendix listing more advanced topics that haven’t been covered.
Programming Perl (O’Reilly) ISBN: 1565921496
Larry Wall, Tom Christiansen & Randal L Schwartz
If Learning Perl is the Llama then Programming Perl is the Camel. This is the definitive guide to Perl. The only more definitve Perl documentation that you’ll find are the POD files that came with your Perl distribution.
This is a reference book and, as such, really isn’t intended to be read cover to cover (but if you do there is enough of Larry, Tom and Randal’s humour in the text to keep you entertained). It covers every aspect of using Perl up to the current version (which was 5.002 when the 2nd edition was written).
The Perl Cookbook (O’Reilly) ISBN: 1565922433
Tom Christiansen & Nathan Torkington
The first edition of the Camel included a section that discussed real world Perl programs. When the second edition was written, Perl had expanded so much that this section had to be removed.The Perl Cookbook is the missing section of the Camel on steroids. It has grown into over 700 pages of examples of Perl code. There are examples to cover just about every application area where Perl is used.
The book starts by covering various way of processing raw data, with chapters looking at text strings, numbers, dates, arrays and hashes, before moving on to regular expressions, files, subroutines, references, packages and classes. The second half of the book looks in considerable detail at application areas like database access, GUI interfaces using Perl/Tk, inter-process communication and CGI.
Mastering Regular Expressions (O’Reilly) ISBN: 1565922573
Jeffrey E. F. Friedl
A little cheating here. Mastering Regular Expressions isn’t really about Perl. It’s an introduction to the concept of regular expressions and their implementation in various languages. However, the Perl implementation is so powerful and regular expressions are so fundamental to Perl that a large number of the examples are in Perl and the last third of the book is dedicated to Perl.
If you consider yourself a Perl expert then you’ll need to know regular expressions well and in order to know regular expressions really well, you’ll need to read this book.
These are general Perl books that most programmers will find very useful.
Advanced Perl Programming (O’Reilly) ISBN: 1565922204
When this book was published, it filled a big gap in the Perl book market. No other book covered advanced Perl topics in any real detail. This book covers things that are only mentioned in passing in other Perl books.
Topics covered include creating modules and objects, Perl/Tk and interfacing Perl code with C using XS or SWIG.
Effctive Perl Programming (Addison Wesley) ISBN: 0201419750
Joseph N Hall with Randal L Schwartz
This book fits somewhere inbetween the The Perl Cookbook and Advanced Perl Programming as it covers a lot of advanced Perl, but does so in a cookbook style. This is a slim volume, but it packs a lot of very useful information into its pages. When I’m stuck of a particularly tricky piece of Perl, this is the book that I generally turn to first.
Perl: The Programmers Companion (Wiley) ISBN: 047197563X
Like Learning Perl this book is an introduction to Perl programming for experienced programmers. This book, however, takes a slightly different approach. Whilst the Llama is aimed at people who are familar with Unix shell scripting tools like sed and awk, The Programmers Companion aims itself at people with an academic, ‘computer science’ background who might be less receptive to the idea of a scripting language that is powerful enough to be used for ‘real programming’.
In targetting this audience, the author makes life much harder for himself, but he succeeds admirably and in the process produces the worlds first really academic guide to Perl.
Although aimed at beginners, the fact that this book takes a slightly different approach to Perl means that most readers will learn something new from it.
Perl In A Nutshell (O’Reilly) ISBN: 1565922867
Stephen Spainhour, Ellen Siever & Nathan Patwardhan
O’Reilly’s Nutshell books are a very simple idea that have been very successful for them. They publish a book that condenses all of their knowledge on a particular topic into one slim volume. My copy of Unix in a Nutshell is probably my most thumbed book.
Perl in a Nutshell is no different. If you have all of the other books that I’ve mentioned then you may not feel that buying this book is worthwhile, but if I’m working on a client’s site, I’ll take a fewNutshell guides (including this one) with me rather than trying to carry my entire library on the tube.
These books concentrate of particular areas of Perl programming. If you’re working in these areas then you’ll find them useful.
Official Guide to Programming with CGI.pm (Wiley) ISBN: 0471247448
Over the past five years, most of the interest in Perl has been from its use in writing CGI scripts. The easiest way to write CGI scripts in Perl is by using the CGI.pm module written by Lincoln Stein. In this book, he explains how to use his module to its best advantage.
CGI Programming on the World Wide Web (O’Reilly) ISBN: 1565921682
When I started writing CGI scripts three years ago, this was the book that I used. The CGI world has moved on a long way in three years (for example, this book has no mention of CGI.pm). This book is, therefore, a little out of date and O’Reilly have stopped printing it. An updated version (with a changed title of CGI Programming with Perl) is due out at the end of this year.
Writing Apache Modules with Perl and C (O’Reilly) ISBN: 156592567X
Lincoln Stein & Doug MacEachern
One of the critisms that you’ll hear of CGI (particularly from Microsoft ISAPI and ASP advocates) is that it is slow. It is true that under traditional CGI a new server end process is started up for each CGI request and this can be slow on heavily used web servers. However, with the Apache web server, there is a well defined API for writing extensions to the web server (called Apache Modules). One of the best known of these modules is called mod_perl. This module effectively embeds a Perl interpreter within the Apache process so that a new Perl session is not required each time a CGI request is made. This speeds up CGI requests tremendously.
This book is a guide to Apache modules (including mod_perl) and covers how to write Perl script that can make use of mod_perl as well as how to write other Apache modules that can extend the functionality of Apache in other ways.
Web Client Programming with Perl (O’Reilly) ISBN: 156592214X Clinton Wong
As I mentioned before, a lot of recent discussion about Perl centres on its use in CGI programming. This books addresses the other end of a web transaction – the web client. Using Perl it is possible to retrieve any data that is available on the web for use in your own programs.
Most of this book is a discussion of the LWP bundle of Perl modules which have been written to make these kinds of tasks easier. Whether you want to pull down some stock prices for a realtime ticker on your desktop, write a robot to index the web or even write your own browser, this book explains techniques to make your job easier.
Programming Web Graphics with Perl and GNU Software (O’Reilly) ISBN: 1565924789
Shawn P. Wallace
When they need to put graphics on a web site, most people will automatically reach for their copy of Photoshop or the GIMP and start creating the graphics by hand. but what if you want to create a hundred button with the same look, but different text? And what happens when you later want to change the look of the buttons, but keep the same text? This book covers the use of Perl scripts to create graphics programmatically. This means that in the button example, you write a program that creates the button and then makes a hundred copies with different text on. When the look changes, you change your program and rerun it.
The book also includes a number of other graphics based tasks that you can use Perl for. Most of the book revolves around discussions of the Perl interfaces to GD, ImageMagick and the GIMP (if you don’t know that any of those are then that’s explained in the book too).
Learning Perl/Tk (O’Reilly) ISBN: 1565923146
This book is the first book to be written about Perl/Tk. Perl/Tk is a module that creates a Perl interface to the well-known GUI development language Tk.
I haven’t yet used this book whilst writing a Perl/Tk program, but the impression the I got whilst reading it was that it was a bit light on extended examples of the topics under discussion. I personally would have liked to have seen a long example running through the book that would have been added to as each chapter’s topic was explained. Perhaps O’Reilly are keeping that for aProgramming Perl/Tk book.
I’m sure that Perlmonth’s lawyers would rather that I didn’t list any books that you shouldn’t buy, so I won’t name any names. I will, however, list some general principles that I apply when deciding to buy a particular book. I would always avoid anything that claimed to teach me a skill in a certain number of days, weeks or months or any book where the title proclaimed that the intended readers were in any way mentally challenged.
When buying Perl books, anything that claims to teach you Perl 4 is over five years out of date and best avoided. One of the most popular Perl/CGI books is CGI/Perl Cookbook by Craig Patchett and Matthew Wright. In chapter 1 they say:
“Although the CD-ROM contains the most recent version of Perl 5, all of the the books programs and subroutines will run under both Perl 4 and Perl 5.”
In other words the code is Perl 4 and you should make your own mind up as to whether you want to learn CGI programming for Perl 4.
I’d like to just mention a few books that are due out in the next few months that will probably be worth taking a closer look at.
I’ve already mentioned the new edition of CGI Programming with Perl. The current news on the O’Reilly web site is that it will be out in December 1999.
One of the most eagerly awaited O’Reilly books for some time is Master Algorithms with Perl by Jon Orwant, Jarkko Hietaniemi and John Macdonald. Latest rumour is that this will be out for the Perl conference. Tim Bunce is also working on a book on DBI programming for O’Reilly . Another rumour from O’Reilly is that a third edition of the Camel is in the pipeline.
Away from O’Reilly, another publisher is hoping to become a major force in Perl publishing. Manning have a number of Perl books in production and a couple will be published in the next few weeks. Object Oriented Perl by Damian Conway has received glowing reviews from all of the reviewers that I have spoken to and I’ve been lucky enough to read Elements of Programming With Perl by Andrew Johnson, which is an introduction to Perl for non-programmers. I thought it was very good.
I hope that this has given you a good overview of the Perl books that are currently on sale. Please don’t blame me if you end up spending too much money at Amazon!
Lastly, a request. RTFM has now been running for four months and I’ve covered most of the topics that I originally planned on writing about. If there are any documentation issues that you would like to see covered in this column, please let me know by emailing me at firstname.lastname@example.org.