Review:The Perl Cookbook 65
Perl Cookbook: Solutions and Examples for Perl Programmers | |
author | Tom Christiansen and Nathan Torkington |
pages | |
publisher | O'Reilly & Associates |
rating | 10 |
reviewer | Eugenia Sotirescu |
ISBN | |
summary | An indispensable compendium of Perl programming problems with expert solutions and commentary. |
The Scenario
The first Perl book, "Programming Perl", (Larry Wall and Randal Schwartz, 1990; aka the Red Camel) included 2 chapters, "Common Tasks with Perl" and "Real Perl Programs", that were left out of the second edition of the book ("Programming Perl", by Wall, Tom Christiansen and Schwartz, 1996; aka the Blue Camel). Many people bemoaned the omission of all these Perl-at-work gems and one of the authors, Tom Christiansen, undertook to expand the 2 orphan chapters into a separate book. Two years later, with the help of fellow Perl programmer and Perl FAQ maintainer, Nathan Torkington, Christiansen gave us the "Perl Cookbook" (aka the Ram book).While no review can even get close to summarizing the wealth of information in this book, its structure is easily described: the organizing metaphor is the cookbook and therefore the bulk of each chapter contains recipes designed to address specific programming problems.
A Code Feast
Here's a brief list of other goodies you can find in this book:- a juicy regex grabbag, that shows how to match HTML links, IP addresses, all-caps words and key=value pairs among many other patterns.
- A full chapter on Database access that in addition to DBI also includes the most extensive discussion of DBM files in Perl literature.
- 40 pages on UNIX processes from the point of view of Perl.
- Examples on how to write demon and non-forking servers in the chapter on sockets and code to create robots, parsing server logs and automating form submission in the chapter on web automation.
- Numerous tips and examples of safe and efficient CGI programming in the chapter devoted to this.
- How to keep your modules separate from the system-wide ones and how to prepare modules you've written for CPAN distro
- Everything you ever wanted to do to dates/time but didn't quite know how .
At times, though, the authors can't keep themselves to just code snippets and
cook a full ready-to-eat meal in the form of a complete program to cap the
solutions presented in a chapter.
At the end of the Pattern Matching chapter,
for example, you can find 'tcgrep', Tom Christiansen's cross-platform supergrep
that "ignores anything not a plain text file, automatically expands
compressed or gzipped files, recurses down directories, searches complete
paragraphs or user-defined records . . . and adds underlining or highlighting of
the matches". A program called 'hopdelta' caps the "Dates and
Times" chapter and shows the time an email message took to reach each
destination based on an analysis of its header.
Anatomy of a Chapter
After an introduction that tries to present the history and general outline of the topic of the chapter come the numbered recipes. Each recipe is divided into 4 parts: a brief statement of the Problem, followed by the code of the Solution and a detailed Discussion with further comments, code examples and pitfalls. The recipe ends with a See Also paragraph that sends the reader to the relevant man pages and further references.Chapter 7, for instance, deals with File Access. It opens with a 4-page discussion of the basic concepts of file handles and I/O. It then quickly moves into the recipes, which range from the basic (opening a file, covered in depth, output flushing) to the often used and asked about (writing a filter, modifying a file) and ends with a longish complete program that implements lock control over a designated region of a file. Changing a file has 3 sections devoted to it: in-place modification using a temp file, doing it from the command line and the less common in-place modification without a temp file.
(Note: if you've been modelling your file locking on the flock() example on pp.166-7 of the Camel book, make sure you check out recipe 7.11, "Locking a File", to see what you may be doing wrong).
What's Bad?
I'd say: nothing. A caveat is in order, though.Good recipes do not a gourmet cook make. A handy compendium of code snippets like the ones in this book will help solve the problem at hand, but won't help you design better programs. I don't mean to detract from the book's value (after all its purpose is not to teach program structure), just to deflate a little the beginning Perl programmer who uses this book to get unstuck: he's solved the problem at hand and that's great, but he's not necessarily a better programmer for it. The authors are probably aware of this, hence the complete programs at the end of the chapters. I only wish there were more of these.
What's Good?
Lucid presentation and clear organization make this book not only useful to refer to, but also pleasant to read through. And the code in it comes not only from experienced authors, but has also been polished by the feedback from scores of Perl gurus, which is a pretty good guarantee of its quality.
Do YOU Need the Ram book?
To make it short, let's actually ask: "who doesn't need the Ram book?"If you're Larry Wall, you probably don't need it . That's it. For the rest of the Perl crowd this book is pretty much an essential companion to the Camel, as both resource and learning tool.
(Note: If you use Perl to teach yourself programming, use the Llama ("Learning Perl," by Randal Schwartz) to get going, but keep the Ram in mind: if you get anywhere with Perl you too will want it).
Buy this book here.
Errata
Table of Contents
- Strings
- Numbers
- Dates and Times
- Arrays
- Hashes
- Pattern Matching
- File Access
- File Contents
- Directories
- Subroutines
- References and Records
- Packages, Libraries, and Modules
- Classes, Objects, and Ties
- Database Access
- User Interfaces
- Process Management and Communication
- Sockets
- Internet Services
- CGI Programming
- Web Automation
Good First book for experience C++ programmer? (Score:1)
ORA needs a good Perl/CGI book (Score:1)
Meanwhile, their web CGI book is a few years old and goes all over the place with Perl, VBscript and Mac stuff.
I'd like to see ORA maybe combine the talents of Shishir, Matt Wright, and Selena Sol in one book.
Someone has to pay for bandwidth (Score:1)
it's ok but not a 10/10 (Score:1)
The big problem I ahve with this book is that it really doesn't work well as a printed book. This needs to be in electronic form for easy search and copy'n'paste! I was lucky to get my hands on a electronic version before it went into print and bought the book later. It was nicer in zeroes and ones (allthough I didn't keep it as it didn't appear very legal).
So I'd say for me it is a 7/10.
M. Wright co-authoring Perl/CGI Cookbook (Score:1)
Matt Wright's CGI scripts are good examples how *NOT* to do it. I don't wanna know what horrible tales he is going to tell in the book.
Who is going to save us from the wave of Wright-taught CGI-scripters wasting our resources?
Anyone ever heard of the other author, Craig Patchett?
Couldn't agree more (Score:1)
I personally learn by example. This book has been invaluable to many projects I have worked on. Its a must buy.
glisters (Score:1)
Yah, right, and the exception TESTS the rule, not PROVES the rule. What's your point, Poindexter?
Perl for Dummies... (Score:1)
I'd like to learn Perl. I have a few applications for it. Unfortunately, I know very little about programming (I was pretty good with GW Basic and QuickBasic... but that was a *long* time ago). I was wondering, what would be the best way for me to back into programming and launch into Perl? Should I try the Camel book? I need a lot of hand holding...
Didn't *anybody* see the humor? (Score:1)
Anonynimity is your friend.
Bug fixes in order (Score:1)
There have been at least two other errors, that I can't remember off the top of my head (nor find in the book on a quick scan, to be honest). All books have errors, but I'm only on chapter two, and minor details like this can be KILLERS in computer books. It's especially disappointing after the flawless presentation in Programming Perl.
Nevertheless, I do recommend it. It saved me hours on the project I'm working on now!
Review or Ad? (Score:1)
I don't have time to read bad books.
There are plenty of good books out there, and those are the ones I read. I review the books I read. Simple.
In that respect, my reviews are less of "this book is good and I recommend it" and try to tackle more of "what this book is about and who it might apply to."
I can't speak for Eugene.
Review or Ad? (Score:1)
I've never ordered from Amazon.
You don't have to either.
Editorial Content (Score:1)
I have no problem giving a poor review to a poor book, even if I received it as a review copy. In truth, I purchase many books every month, have an enviable professional library as a result, and spend a significant portion of my personal time reading and absorbing them.
In practice, I only tend to read useful and good books, so that weeds out poor reviews as a side effect. Anyone is free to disagree with my reviews, and to purchase or not purchase the book in question as they see fit.
I don't purchase at Amazon, mostly because I'd just as soon order it at a local store. Price is not an issue for me personally, since I make a decent (though by no means complete!) salary.
YMMV
Own experience... (Score:1)
btw, I've been programming Perl professionally for well over 3 years... guess it kinda makes a difference. I would say that most people would find APP quite useful.
However, I will check out the perl cookbook. I'm particularly interested in the bit on daemons.
The bit on efficiency and programming style near the end of the Camel Book is quite good too. The bit on how to style programming was interesting - it is almost identical to what I do! (I was already doing things that way before I read it...)
Review or Ad? (Score:1)
Awesome Book (Score:1)
The organizational structure of the Cookbook allows it to be not based on the language functions, but on what you want to do.
I use this book more than my copy of Programming Perl, and feel it is essential for learning Perl. Mostly because the text Learning Perl doesn't support you in the high-end ideas you try to complete. This book was one of my favorite purchases and most used books. 11/10.
The Llama book is your friend (Score:1)
My parents gave it to me for my birthday (well I did hint pretty heavily).
I've already worked through half the book and have actually used Perl in my job now.
Definately get it.
Kashani
Read carefully... (Score:1)
Review or Ad? (Score:1)
There's tons of them...
Price Check (Score:1)
BarnesAndNoble $31.96
Bookpool $24.95
Shopping $19.97
Spree $31.96
Regards, Ralph.
Review or Ad? (Score:1)
Read the "Amazon Info" box by the review: "The books here are brought to us in Partnership with Amazon.com. If you follow the links around here, and eventually buy a book, we get a percentage of the cost!" The openness of the relationship is about the only thing that makes it acceptable to me.
Seen negatively: The books reviewed are rather too often surprisingly expensive non-discounted books at Amazon, when they can be had *much* cheaper elsewhere. Here I start to smell a rat. Especially when the reviewer attempted to include pricing info from other sources but had the info edited out by Slashdot (as happened in this review).
If the Slashdot affect works for book sales like it does for websites then CmdrTaco and Co. can be making a pile of cash off these reviews. If so, it can't be so healthy for a
But who can you trust in this respect nowadays, anyhow?
Regards, Ralph.
It *is* a learning tool too (Score:1)
If the book was just snippets and descriptions, this would be true. But in most cases, a step-by-step description of how the code works is provided. This allows the reader to learn from the examples, not just blindly copy them.
Limited $$ choice? (Score:1)
Another recommended book is "mastering Regular Expressions" by Jeffrey E.F. Friedl. It explains regex for pretty much everything. (Not just Perl.) One of the most useful O'Reilly books out there.
Is there a C cookbook? (Score:1)
Not essential, but useful nonetheless (Score:1)
Programming Perl
Advanced Perl Programming
Accept no substitute
Perl for Dummies - exactly (Score:1)
lot more help than Learning Perl, but I still
refer to both.
I just picked up the Perl Cookbook, and it looks
like it will also be a huge benefit. I've
reinvented the wheel (badly) several times for
lack of good practical examples like these.
Review or Ad? (Score:1)
I take the point about making money from sales, but perhaps if anyone is writing really acid reviews you could include them for sheer entertainment value.
It's cheaper at buybooks.com than amazon (Score:1)
O'Reilly: $39.95 oreilly.com
Amazon: $31.96 amazon.com
BarnsAndNobel: $31.96 barnsandnobel.com
BooksAMillion: $31.96 booksamillion.com
Books: $31.91 books.com
BuyBooks: $25.16 buybooks.com
I was considering writing a free search engine
that would find the cheapest book, CD, or Video
by looking through the various sites. Do you think people would be interested in something like that?
It's cheaper at buybooks.com than amazon (Score:1)
Call it FREE, make it FREE and we all get rich!
;-)
Search for the Cheapest Book Prices on the Net! (Score:1)
I'd be interested in any feedback.
Check it out at:
http://expert.cc.purdue.edu/~bgann on/booksearch/ [purdue.edu]
Good First book for experience C++ programmer? (Score:1)
Learning Perl is an AWESOME intro book!! (Score:1)
Limited $$ choice? (Score:1)
Errata (Score:1)
2.Here's a list of prices (edited out):
shopping.com: $19.95
bookpool.com: $26.50
amazon.com: $31.96
Eugene Sotirescu
Limited $$ choice? (Score:1)
ORA's web site has some excerpts tho.
The price is kinda steep, but check out bookpool's price ($90, $60 off the store price!) if you decide to go with it.
If you haven't done OO in Perl, the Kit might help you use modules that need OO code (the pods are often stingy).
Review or Ad? (Score:1)
1.You can't draw a meatcleaver distinction between decription and recommendation. "what this book is about and who it might apply to" often carries an implicit recommendation.
2.The "Perl Cookbook" is a special case. I don't know many tech books that reach this quality of both code and delivery and can sustain it through over 400 pages. That's why this it gets an 'unmixed', "this book is good and I recommend it" review.
It *is* a learning tool too (Score:1)
ORA needs a good Perl/CGI book (Score:1)
Volunteerism (Score:1)
All software sucks, some just suck less than others.