Learning Perl, 4th Ed.
Craig Maloney writes "Just about everyone out there who has ever typed #!/usr/bin/perl has encountered Learning Perl (otherwise known as "The Llama Book") in one form or another. You may have learned some of the intricacies of the language from this tome, or you've seen someone recommend this book to potential Perl programmers on-line. Learning Perl is generally in the top three recommended books for new Perl programmers, next to Programming Perl ("The Camel Book"). Now in its fourth edition, Learning Perl returns with updates covering the stable 5.8 series of Perl. The changes are subtle, but the improvements make for a clearer and more readable book." Read on for the rest of Maloney's review.
Learning Perl, Fourth Edition
author
Randal L. Schwartz, Tom Phoenix and brian d foy
pages
304
publisher
O'Reilly
rating
9
reviewer
Craig Maloney
ISBN
0596101058
summary
The fourth edition of the classic text for learning the Perl language.
When I was initially introduced to Perl, I was one of those who was recommended to read Learning Perl. I picked up the initial edition (with the mauve binding), and began my journey into Perl. What I found was a dense, hard-to-follow introduction to the language, with the experienced Perl programmer in mind. I realized that the tutelage of this experienced programmer/author might be useful, but I opted for other books instead. As others looked to me for book recommendations, I recommended other works for people looking to immerse themselves in Perl, and relegated Learning Perl to the section of my library where live books with a steep learning curve (similar to the learning curve experienced by many with Kernighan and Ritchie's classic The C Programming Language). Like The C Programming Language, however, a full grasp of the language is not achievable from texts where the central focus is to avoid using the lingo and customs of those who are more familiar with the language. Only by full immersion in the culture of the language can one become fully proficient in that language. What's new? Learning Perl 4th edition has been updated in several ways from the previous edition. The text has been updated to reflect Perl 5.8, although this book doesn't introduce any 5.8 specific concepts. The new edition was reorganized from the previous version. The chapter on Regular Expressions is enhanced, and file handles are introduced in the I/O Basics chapter. CPAN is introduced in Learning Perl, since it has become much more important to beginners. The chapter on flat-file databases (DBM/DBM Hashes) didn't make the cut for this edition, but a good portion of the chapter made its way into Chapter 9 (Processing Text with Regular Expressions). The book has a cleaner feel to it, and flows without the erratic feel of the previous editions. What's good Learning Perl could rightly be called A Tourist's Guide to the Perl Culture. The material is immersive, and teaches Perl using the verbal language of a Perl programmer. No attempt is made to dumb down the material. This leads to sentences in the book like the following: Alas, these aren't words as you and I are likely to think of them; they're those \w-type words made up of ordinary letters, digits, and underscores. The \b anchor matches at the start or end of a group of \w characters. The previous sentence makes perfect sense for those who have already grasped the fundamentals of regular expressions, but for those who aren't quite up to speed, the previous sentence warrants further study. This can be a blessing or a curse for some. Ultimately, it forces the reader to understand the Perl culture which can only improve the reader's understanding of Perl. Also of note are the footnotes. Almost every page in the book contains footnotes commenting (sometimes sarcastically) about the topic at hand. Sometimes the footnotes can be distracting, as your eyes will busily look for the next humorous footnote, such as this little gem: And /,{5}chameleon/ matches "comma comma comma comma comma chameleon". By George, that is nice. What's Bad The only complaint I can level at Learning Perl is that there could be more explanation for some of the concepts in the book. In the section called "More Regular Expressions," the book presents the following example:
What's in it for me? Learning Perl would rightly be regarded as one of the classic texts for Perl programmers to read through at least once in their Perl careers. The book is chock-full of useful information, and even experienced Perl coders would do well to at least leaf through the pages of this book for paradigms to help their coding. Absolute beginner programmers would likely find this text a little over their heads, but intermediate programmers will find Learning Perl a valuable resource in their road to proficiency with Perl. You can purchase Learning Perl, 4th Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
When I was initially introduced to Perl, I was one of those who was recommended to read Learning Perl. I picked up the initial edition (with the mauve binding), and began my journey into Perl. What I found was a dense, hard-to-follow introduction to the language, with the experienced Perl programmer in mind. I realized that the tutelage of this experienced programmer/author might be useful, but I opted for other books instead. As others looked to me for book recommendations, I recommended other works for people looking to immerse themselves in Perl, and relegated Learning Perl to the section of my library where live books with a steep learning curve (similar to the learning curve experienced by many with Kernighan and Ritchie's classic The C Programming Language). Like The C Programming Language, however, a full grasp of the language is not achievable from texts where the central focus is to avoid using the lingo and customs of those who are more familiar with the language. Only by full immersion in the culture of the language can one become fully proficient in that language. What's new? Learning Perl 4th edition has been updated in several ways from the previous edition. The text has been updated to reflect Perl 5.8, although this book doesn't introduce any 5.8 specific concepts. The new edition was reorganized from the previous version. The chapter on Regular Expressions is enhanced, and file handles are introduced in the I/O Basics chapter. CPAN is introduced in Learning Perl, since it has become much more important to beginners. The chapter on flat-file databases (DBM/DBM Hashes) didn't make the cut for this edition, but a good portion of the chapter made its way into Chapter 9 (Processing Text with Regular Expressions). The book has a cleaner feel to it, and flows without the erratic feel of the previous editions. What's good Learning Perl could rightly be called A Tourist's Guide to the Perl Culture. The material is immersive, and teaches Perl using the verbal language of a Perl programmer. No attempt is made to dumb down the material. This leads to sentences in the book like the following: Alas, these aren't words as you and I are likely to think of them; they're those \w-type words made up of ordinary letters, digits, and underscores. The \b anchor matches at the start or end of a group of \w characters. The previous sentence makes perfect sense for those who have already grasped the fundamentals of regular expressions, but for those who aren't quite up to speed, the previous sentence warrants further study. This can be a blessing or a curse for some. Ultimately, it forces the reader to understand the Perl culture which can only improve the reader's understanding of Perl. Also of note are the footnotes. Almost every page in the book contains footnotes commenting (sometimes sarcastically) about the topic at hand. Sometimes the footnotes can be distracting, as your eyes will busily look for the next humorous footnote, such as this little gem: And /,{5}chameleon/ matches "comma comma comma comma comma chameleon". By George, that is nice. What's Bad The only complaint I can level at Learning Perl is that there could be more explanation for some of the concepts in the book. In the section called "More Regular Expressions," the book presents the following example:
Here's the text:Unfortunately the less astute reader may not understand what exactly happened here. One line of output with the end result would help clarify what this regular expression did.
I'm talking about the cartoon with Fred and Wilma!And here's a substitution to remove those tags. But what's wrong with it?
s#(.*)#$1#g;The problem is that the star is greedy. What if the text had said this instead?
I thought you said Fred and Velma, not WilmaIn that case, the pattern would match from the first to the last , leaving intact the ones in the middle of the line. Oops! Instead, we want a non-greedy quantifier. The non-greedy form of star is *?, so the substitution now looks like this:
s#(.*?)#$1#g;And it does the right thing.
What's in it for me? Learning Perl would rightly be regarded as one of the classic texts for Perl programmers to read through at least once in their Perl careers. The book is chock-full of useful information, and even experienced Perl coders would do well to at least leaf through the pages of this book for paradigms to help their coding. Absolute beginner programmers would likely find this text a little over their heads, but intermediate programmers will find Learning Perl a valuable resource in their road to proficiency with Perl. You can purchase Learning Perl, 4th Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Finally, a book review that's actually a review and not a summary or a novel in itself. Well done.
I've got a question. I haven't read through it yet, but I've got a borrowed copy of 4th edition. Should I bother to read through it, or should I hold out for finding a 5th ed?
One of the goals of Perl 6 is to make non-trivial projects possible. That's good. The way it's being done is bad. Perl was once a lightweight, extremely flexible language. Now it's become a huge ugly monster. People wanted OO, so a nasty hack was bolted on top to allow some semblance of it. Now this nasty hack is being expanded. Sure, the code's different, but the basic form is the same. Kludge upon kludge upon kludge; I'd much rather have a nice, clean, pure language (and not one with loads of irritating whitespace thank you very much).
The same goes for the syntax. All the switching between $, @ and % is really irritating (ask a newbie how to get at the length of the keys array of a hash inside a hash, for example), and the changes proposed for 6 are just making this worse -- it seems that Larry, in his infinite wisdom, wants to prefix every data type with a different hard-to-type character. Perl was only designed for the three data types, and adding more is a mess.
Perl 6 is a complete rewrite, but it keeps all the mess which has accumulated over the previous versions. This is not good. Sure, my const int $var = 27; may look neat (in the same way that, say, Pascal does), but $var isn't entirely constant, or entirely an integer, it's just a hack which makes it sort of behave like one. The whole thing is an exercise in pseudo-computer science masturbation with little real purpose except to please the managers who dislike the one thing that makes Perl special.
On a similar note is regexes. I'm an avid fan of regular expressions simply because a nondeterministic finite automata is far more flexible than linear code. However, Larry must have been smoking that cheap $2 crack when he wrote this. Does he want Perl 6 to be flex or something?
I won't be going on to use 6. It's a nice idea, but it's completely unnecessary. It won't make large projects any easier to manage (the language is still, at heart, an almighty hack -- an impressive one, but still a hack). It won't make OO any cleaner. It won't make development any faster. To put it bluntly, Perl scripts will still look less beautiful than our friend Mr Goat.cx. I'd prefer to use a language which has always been pure synthesis of science and engineering, not some half-baked imposter.
Perl 6 will be nice, but I'm guessing it will be the end of Perl. It can't do what it wants to do whilst still being based upon a nasty mess. There are now other options, which provide all of Perl's power and none of the mess. Sorry, but *BSD^H^H^H^H Perl is dying. Larry is buggering it up the ass without lubricants, just like Shoeboy is doing to Larry's daughter.
...since half the people in that room have a bind setup to spam the address of Learning Perl in response to any question, no matter how obscure. One wonders why they bother.
Fortunately, perl is headed into a blessed obsolescense... here's a hint as to why. Cheers!
political_news.c: warning: comparison is always true due to limited range of data type
Hook you index and middle finger slightly while holding them together. Keep your thumb, ring finger, and pinky down. Place the side of your hands on the top your head between your temple and your ear. Rotate slowly. No I don't remember the reference but its funny as hell when a whole group of people doesn't it while shouting "Internation Order of the Llama!"
If brevity is the soul of wit, then how does one explain Twitter?
/Sorry, couldn't resist... //Now in my 9th year of Perl
Can someone explain the "What's Bad" section of the review? I don't quite get what either the author or the reviewer is trying to explain...
I do mostly PHP now, because of whom I'm working for. But I've used Perl in the past and still do(when it's easier/faster to do it than PHP and no one will notice). Nothing really web wise for it, but it still fits nicely where other things don't.
That's what I've always liked about Perl, it fills the void. Before PHP it was the CGI king, now PHP and ASP share that. But it's still there when you need it.
I've been meaning to check out mod_perl2 which I've heard is finally stable. Anyone try it out yet? Comparisons to mod_perl1? That's the thing I miss in PHP, a lot of that functionality(mod_perl) is missing. But PHP works just fine. (Let's not start a flame thread under me, I'm sure there are plenty of other threads that are gonna erupt into flames).
Here's the text:
I'm talking about the cartoon with Fred and Wilma!
And here's a substitution to remove those tags. But what's wrong with it?
s#(.*)#$1#g;
Uh... everything? What tags? Am I nuts, or doesn't s#(.*)#$1#g; always replace the entire string with itself? What could be more useless?
Larry is my savior.
Learning Perl is generally in the top three recommended books for new Perl programmers
The other two being this one, and this one.
"A door is what a dog is perpetually on the wrong side of" - Ogden Nash
> s#(.*?)#$1#g;
But why the cartoon swearing??
No folly is more costly than the folly of intolerant idealism. - Winston Churchill
While, ultimately, I'm reserving Perl as a skill ONLY used when absolutely necessary (ie. when I get stuck debugging someone else's code) - I didn't like Learning Perl, or Programming Perl, or Perl in a Nutshell. All three of these books left me frustrated and completely lost.
In sharp contrast, the Perl Cookbook, gave me answers to all of my questions. I recommend Perl Cookbook to anyone. The other books? Only to masochists.
These are my friends, See how they glisten. See this one shine, how he smiles in the light.
I really don't get the whole pattern matching in perl. Give me something that is straight forward like in objectscript Variable?3N1"-"3N1"-"4N to verify a telephone number. How easy is that?
Example makes no sense.
$ echo "I'm talking about the cartoon with Fred and Wilma!" | perl -pe 's#(.*)#$1#g;'
I'm talking about the cartoon with Fred and Wilma!
$ echo "I thought you said Fred and Velma, not Wilma" | perl -pe 's#(.*?)#$1#g;';
I thought you said Fred and Velma, not Wilma
there I said it.
from the looks of it, seems like a nice book but what we need is, a book that beats people into submission so that they make READABLE perl ..
99% of the perl i look at makes me want to kill someone.. (i make sure someone else is in the room)
'...if only "Jumping to a Conclusion" was an event in the Olympics.'
The text has been updated to reflect Perl 5.8, although this book doesn't introduce any 5.8 specific concepts.
So how exactly does this edition "reflect" Perl 5.8 then? Is is it enough just to drop a reference to 5.8 and leave it at that? This book is nothing more than a cynical O'Reilly marketing exercise. The sample chapter from O'Reilly is identical to the corresponding chapter in the 3rd edition while a brief look at the table of contents shows nothing more than a re-arrangement of the previous edition. Anyone who has the 3rd edition will be wasting their money buying this book.
Sounds interesting. Does anyone know whether there's gonna be a 4th edition of Programming Perl (the Camel Book) anytime soon, too?
quidquid latine dictum sit altum videtur.
Here's the text:
I'm talking about the cartoon with Fred and <BOLD>Wilma</BOLD>!
And here's a substitution to remove those tags. But what's wrong with it?
s#<BOLD>(.*)</BOLD>#$1#g;
The problem is that the star is greedy. What if the text had said this instead?
I thought you said Fred and <BOLD>Velma</BOLD>, not <BOLD>Wilma</BOLD>
In that case, the pattern would match from the first <BOLD> to the last </BOLD>, leaving intact the ones in the middle of the line. Oops! Instead, we want a non-greedy quantifier. The non-greedy form of star is *?, so the substitution now looks like this:
s#<BOLD>(.*?)</BOLD>#$1#g;
And it does the right thing.
Some may consider this a troll, but, knee-jerk reactions aside, from a professional standpoint, unless you have to maintain some legacy system that uses Perl, or an interest in historical programming languages, there is very little point in learning Perl. You can find all of its benefits in more modern non-compiled languages without the cruft of years of esoteric development. I will not mention other languages as that will just start a religious war over everyone's pet language, but, seriously, aspiring technologists take note and do your research.
If you already know Perl, that's great and good that you learned it when you learned it, but it doesn't change the above.
I joke, I joke. I have Visual Python!
... or back up your vague assertions with anything more solid than "because I said so".
how to invest, a novice's guide
I'm not the original poster, but here you go:
- Perl Puzzles
- Perl Periodic Table of Operators
More than enough to send me running screaming...Mike
"Not an actor, but he plays one on TV."
Okay, I am one of those, generalists, prgrammer wannabe.
I have spent time with, C, C++, Objective-C, OCaml, Python, Java, Bash scripting, Perl, Tcl, Sql and maybe others.
And even thought Python was kind sometime, my main pick, I had to give up on it.
Python is hard, harder to learn than even C.
Learning how to program in OO, is hard, and python, regardless of what you say doesn't make it easier.
To really understand the different programming paradigm, you have to learn more than one language, an programmer who haven't look on at least 5 languages shoul question his own skills.
Anyway, Perl biggest assets in my opinion, are
- The wealth of it's literature, you can find a Perl book covering almost any programming corner and topic.
- That Perl book, will be effectively teaching you a CPAN library
Python, will never have that, mainly because no other language have that, Perl is unique in this. Plus OO programming, is just tuff to swallow, in theory, I would say OO offer a very nice level of uniformity and abstraction to any program, but in real life, it's just easier to deal with the mess of procedurla programming. And don't think of data, and behavior owners.Good luck with your Pythonic dreams, but
Sigh.
...just to remind me that there are things in this world less sane than C++ but oddly more seductive.
The other Perl books I keep in my private collection with my BSD books hidden behind a box of pr0n tapes and DVDs so no one thinks I'm a total perv.
If my grammar and spelling are off, I am [distracted/tired/careless] (take your pick)
Learn Ruby instead. Your fellow programmers will thank you.
Learning Perl is generally in the top three recommended books for new Perl programmers, next to Programming Perl ("The Camel Book")
Programming Perl (Camel Book)
Learning Perl (Llama Book)
Okay, I'll bite. What's the third book?
So, learning Perl today may actually increase your job potential. New startups are happening all the time, including projects that are shifting away from Java and dot-net, and toward real workable open-source solutions.
Seriously, I was a perl fanboi a long time ago. Of course I'd love to use Lisp or something but Perl's so darn *practical*. Or pragmatic, if you will. And you can still do a lot of cool stuff like pass anonymous code blocks around or "roll your own" object system.
But come on, Perl stopped being cool maybe 5 years ago. I remember when I started using Perl 5. I thought the objects were cool. I started dreaming of a powerful object oriented interpreted language with the power of Perl but a sane syntax.
I tried Python 1.5, couldn't quite "get" the vibe of it, it felt bolted together from random parts, some design choices just didn't make sense. (Tried it again recently, still doesn't make a lot of sense.)
Then I discovered Ruby 1.6 (via the Dr. Dobbs article like many others). WOW! The power of Perl but AWESOME lightweight syntax and consistency. Truly a beautiful language. I can't imagine EVER going back to Perl. In Ruby you don't have to choose between "==" and "eq" for instance.
And some of my friends who didn't like Perl went to PHP because it was simpler. Less powerful sure, but easier to get things done.
Now Perl 6 is coming up and it looks AWFUL. Like somebody didn't just put in everything but the kitchen sink, but EVERY BLOODY TYPE OF KITCHEN SINK THEY SELL! Just too much for my little brain. It's Ruby for me. As soon as Ruby gets a real VM and unicode support, it will be the only language I need.
So again I ask the question.. why perl?
I encourage you to review every article I've written there, and come to your own conclusion. I'll stand by my public record.
Save yourself more than FIVE BUCKS by buying the book here: Learning Perl, 4th Ed.
I am learning Perl using Beginning Perl
And I am really satisfied with it, it's free, it's comprehensive and it's author is a skilled Perl hacker.
I would like to know, what more does Learning Perl have to offer? (For one it's not free!)
If it's depth, I plan to use the perldoc and perlmonks.org for the depth. And beginning perl just for the big picture (not that it doesn't offer depth, it does to a great degree).
I will not mention other languages... ... or back up your vague assertions with anything more solid than "because I said so".
His statement needs no backing up. Anyone who has
actually programmed anything major already *knows*
there are better languages out there.
I'm not sure if its still true but the last time I checked /. uses mod_perl and template toolkit to run most of the show.
if ($php == 'Personal Home Page') {
$code = 'good language to learn basics';
}else{
$code =~ s#(slashdot.org)#/.#;
}
If exposure to C++ hasn't destroyed your ability to think logically, you should have no trouble with math. Leslie Lampo
irc.perl.org. That is all.
"Having encountered Randal L. Schwartz on PerlMonks I find him agressive, unprofessional, and unknowledgeable." I wonder who you are then, besides an Anonymous Coward...
Perl Programmer for hire
I just read the last 40 posts of one Mr Randal L. Schwartz on PerlMonks as per his link here and found none to be aggressive or unprofessional and instead helpful if not patient. Sorry AC you must have some axe to grind.
He may have falsely impugned your credentials, but it hardly rises to libel. As another online acquaintance of mine said: "if there isn't some mentally deranged person yelling at you from the streets, you aren't really accomplishing anything in the world."
Don't rise to the bait.
I am no longer wasting my time with slashdot
The reason I use and recommend perl over other languages is the useful INDEXED source of common modules called cpan.
This single resource has saved me many hours of programming alone. More than pays for some of the obscure problems. Frankly it is up to the programmer to write good code, not the programming language. I can show you horrible code in about 20 different languages from Cobol to C to Java to Perl. Learn how to write and comment clearly and any language is a good language.
"Tome" generally implies that a book is more-or-less comprehensive and rather thick. Learning Perl is more like a quick introduction. "Code Complete" is a tome. "Life with Qmail" is a tome. And "The C Programming Language", now *that's* a tome. "Learning Perl" is not in this class at all.
"No problem. I have the capacity to do infinite work so long as you don't mind that my quality approaches zero."-Dilbert
nope. you are fairly rude. hell you made a sig just to excuse yourself for being so. many people have told you too. man what a jerk
Opinion is not libel.
Based on this comment alone of yours, I now have to agree with him. You are a pompous asshole with an attitude problem.
While this may be off topic if your really interested in learing about Regular Expressions the subject deserves more then just a chapter out of the pearl book. "'Mastering Regular Expressions" by o'reilly is an excellent book on the topic
the camel book refreshed my memory and brought me to the basics of programming.. like learning about variables and arrays.. the book definitely gave me a good review on the concept of programming.. then it takes you right into examples, and practical uses.. i'll probably pick up this 4th edition.. sounds like a bargain..
*plays the Apogee theme song music*
Good one Larry, had us going
I've begun programming with Learning Perl 1st Ed, almost 8 years ago. I was a highschool student then, and had almost no programming experience (which is to say : I had learned how to program a bit of ASM for a Motorola 6809 chip, which had 2 registers only, so you couldn't do much complex programming with it).
I litterally learnt how to program and - even more important - how to think before beginning to code thanks to the Llama Book.
When later I began my CS studies, programming wasn't a problem at all.
Repectfully disagree. For some people, programming languages are just one small tool of many, rather than being the focus of the job (e.g. scientists).
/some_regex/' have saved me loads of time to do other, more interesting things. Call it a glorified awk or sed, but it's a huge time-saver.
Suppose I have several large datafiles, and I need a subset of the data from all of these in a different format. Perl is the best tool I've found for dealing with that. Variations on perl -ne 'print if
The win32 modules shit all over vbscript or command scripts for messing with AD :D
So there's a use for people who don't know it yet - i'm sure there's plenty more.
smash.
I run: Windows, OS X, Linux, FreeBSD. Just because you have a hammer, doesn't mean everything is a nail.
From a professional standpoint, there are plenty of open positions at the very large company I work for that call for Perl in new development projects. Methinks your bias is showing.
I live ze unknown. I love ze unknown. I am ze unknown.
I also think Perl 6 is a mistake, and I'm not going to post anonymously. After years of writing Perl, I've switched to Ruby after seeing the direction Perl 6 was going in.
I always felt that Perl 5 needed some drastic cleanup and simplification. I never got the hang of writing proper OO libraries, because it was so painful and non-obvious. While that's somewhat fixed in Perl 5, there's a whole new load of complexity being introduced.
I don't want variables to have different syntax depending on whether they're object variables or normal variables. I don't want method dispatch to maybe follow different rules to inheritance. I don't need MetaClass and Class to be separate things in the language; I'm quite happy for it to be turtles all the way down. And most of all, I don't need full regular expression interpolation in freakin' package names!
I realized that not only is it really hard to make something complicated and powerful into something simple and powerful, it's also not Larry Wall's direction for Perl 6. A new piece of syntax for private methods as well as a private trait, and they work slightly differently? Methods which are either class methods or object methods depending on what the calling code does? The man certainly has a talent for introducing gratuitous complexity.
GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
I suppose if it were Perl 6, it would be funnier, because the parrot virtual machine is atttempting to do a few of the same things as CLR. http://www.perl.com/pub/a/2002/03/19/dotnet.html ;-)
I made this attempt at humor about Python and Perl flamewars, which started early here, because both groups tend to also be "open source" purists, and I find it funny that evil empires' borg-like platform embraces both languages. I also noticed that despite having the book, you don't claim to be using it!
Well I read The Camel Book and had to read it 3 times before I understood half of what it was saying. I am looking forward to picking up this new copy but wonder if they make a audio version or video version? And if so the link where I can pick it up. Thanks for any help on this issue.