| Buy it |
| Talk about it |
| Usenet Reviews |
| Search for more items by Tom Christiansen & Nathan Torkington |
This is probably the most useful Perl book I own. Whenever I need a solution quickly--which is often here at the University--I am very likely to find my start in the Perl Cookbook.
| Recommendation: Special Interests Only | |
| Writer: Tom Christiansen, Nathan Torkington | |
|
Rating: 5 |
|
When we switched from PH to LDAP, everyone else wanted to not support older e-mail readers. I grabbed the Perl Cookbook, found the simple telnet server, and quickly modified it to gateway between PH and LDAP.
At first glance, this is a huge book, with lots of recipes inside for programming in Perl. A lot of the recipes appear to be trivially obvious--whereby trivial, I mean that it would take less time to write the solution myself than to find it in a 750 page book. Others are not, however, and no doubt what I consider trivial others do not, and what authors Christiansen and Torkington consider trivial, I do not. This is a lot like the kind of answers you would get posting questions to the net, except that these are (hopefully) working examples rather than created off-the-cuff with debugging opportunity provided as an exercise.
Sometimes its weird seeing familiar names in unfamiliar places. I remember Tom Christiansen from my Dungeons & Dragons days. He was one of the early crew at TSR and lived next door to Gary Gygax. He (as did I and probably a whole generation of coders) did some of his earliest programming writing character generation tools for role-playing games.
There is not, unfortunately, any of that in Perl Cookbook. There is just about everything else, however. I just opened it randomly to page 218, and found the Regular Expression Grabbag. Regular expressions for grabbing Roman numerals, grabbing dates and times, grabbing links from HTML. One of the sections I use most often is the sockets section, chapter 17. Theres Writing a TCP Client which implements a simple means of connecting to TCP/IP servers, and Writing a TCP Server, which implements a simple means of waiting for clients to connect over TCP/IP.
There is a small chapter on CGI programming, which includes recommendations to use the CGI module. But many of your CGI problems will have solutions in more specific areas. Browsing through the book (and if youre a real Perl programmer, youll probably browse through this book simply for the fun of reading it; it makes better bathroom reading than most) I see in Numbers a recipe for generating weighted random numbers, for example to randomly select a banner to display on a web page, given a set of relative weights saying how often each banner is to be displayed.
There are sections on using TK to provide a more robust user interface, object-oriented programming in Perl, strings, numbers, dates and times (the same thing in Unix), arrays, hashes, pattern matching, file and directory access, subroutines, packages, databases, process management, sockets, and even web automation (automating access or updates to web pages). It provides a useful index for finding the solutions in these sections. (Just glancing through for this review, I discovered something to do with Expect in Perl, which could ease some problems Ive been having using Expect in CGI programming.)
Something that would have been useful, which I dont see, would be instructions on the use of CPAN to grab modules, since often the solutions presented here require or at least recommend the use of one or more non-standard modules. Theres a tiny section on installing modules that youve already downloaded, but nothing that I can find about using the command-line CPAN interface to more easily install them from scratch. (In their favor, it may be that when this book was published in late 1998, the CPAN interface had not yet been standardized.)
Perl Cookbook was created as a companion to the Programming Perl reference and tutorial (the camel book). The first edition of that book had chapters on Common Tasks and Real Perl Programs. Those chapters were removed from the revised camel due to space considerations. This is a monster expansion of those original two chapters. This means that it includes some incredibly simple common tasks as well as some more complex real programs.
If you use Perl regularly, youll probably find this useful. This is one of a rare breed of books that I purchase two copies for, one for the office and one for home. It was developed using Perl 5.004_04, so the examples will work best with that version or later
Buy Perl Cookbook at Amazon!
Search for more items by Tom Christiansen & Nathan Torkington
| Talk about it | Usenet Reviews | Talk about Tom Christiansen, Nathan Torkington |
| Other items of interest: Javascript: The Definitive Guide; | ||
If you have comments or questions about this page, please, leave a message on the Negative Space Comments Page.
| Negative Space |