Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Perl Books Media Programming Book Reviews

Learning Perl, 4th Ed. 172

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:

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;
The problem is that the star is greedy. What if the text had said this instead?
I thought you said Fred and Velma, not Wilma
In 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.
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.

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.
This discussion has been archived. No new comments can be posted.

Learning Perl, 4th Ed.

Comments Filter:
  • Refreshing... (Score:4, Insightful)

    by op12 ( 830015 ) on Tuesday July 26, 2005 @04:09PM (#13170087) Homepage
    Finally, a book review that's actually a review and not a summary or a novel in itself. Well done.
  • Question (Score:4, Interesting)

    by rk_cr ( 901227 ) on Tuesday July 26, 2005 @04:11PM (#13170120)
    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?
    • Re:Question (Score:3, Funny)

      by Tackhead ( 54550 )
      > 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?

      According to the Slashdot blurb up there, "The changes are subtle, but the improvements make for a clearer and more readable book."

      So I'd say - if you enjoy Perl, stick with the 4th edition. All those backticks, quotation marks, slashes, and punctuation marks are there for a reason. Subtlety? Yes. But for readability?

    • According to the O'Reilly page for the book [oreilly.com], the 4th Edition it has a publication date of July 05. The 3rd Edition was published in July 01. So, I'd say it'll be at least a couple of years before a 5th Edition comes out. If you can hold onto that borrowed copy for that long, then waiting would make more sense. But my guess is that whoever you borrowed it from will want it back before the 5th Edition is published.
    • Re:Question (Score:4, Informative)

      by merlyn ( 9918 ) on Tuesday July 26, 2005 @06:10PM (#13171362) Homepage Journal
      We pitched this book to O'Reilly as "the last edition before Perl6 comes out". So, that's the scoop. One last chance to get Learning Perl for Perl5 correct. And apparently, we did the job.


      • Maybe I'm just brain numb from tonight's DARPA Grand Challenge meeting Go IRV! [indyrobotics.com], but can you explain this?

        The text has been updated to reflect Perl 5.8, although this book doesn't introduce any 5.8 specific concepts

        This almost sounds like Twin Sons of Different Mothers


  • Perl6 is a mistake (Score:2, Informative)

    by Anonymous Coward
    I've been using perl pretty much constantly since the Pink Camel, and believe me, Perl 5 is an extremely good language for quick scripting things. That's what it was designed for. Sure, you can do big projects in it, but it's not exactly ideal. Recently I've started using Ruby [ruby-lang.org] as well, and I intend to move my department over to it instead of wasting time with Perl 6.

    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

    • 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.

      Admittedly, perl 5 OO is rather hackish, but Perl 6 OO truly is different. Instead of taking some random object and blessing it to a package, Perl 6 makes classes first-class objects, and allows instances to be created, just as in most other OO programming languages. Yes, even ruby.

    • 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
  • ...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 [taupehat.com] a hint as to why. Cheers!
    • ...since half the people in that room have a bind setup to spam the address of Learning Perl in response to any question,

      And that's one of the reasons why Perl is heading into oblivion. Rude users. Sometimes I'll be there, a newbie will ask a newbie question, and 5 zealots will jump down their throat.

      Worse then #debian sometimes, and that's hard to beat.
    • What's that you say? A pedantic language that requires you to use whitespace to specify blocks and doesn't massively improve on Perl is going to replace Perl, given that many Perl programmers wouldn't bother switching because of the former reason _alone_, not to mention the fact that they're already satisfied with the ease and elegance of Perl?
    • Wait. I don't get it.

      Is the Python headed to the Perl funeral home to pay his respects to his dead buddy fortran?

    • Why? Mainly the OO paradigm, big turn off

      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
      • > Plus OO programming, is just tuff to swallow

        I smell a spelling troll. Makes the rest a bit suspect.

        If you are serious, then well, sorry you couldn't hack it. Java I'd accept as an example of enforced OO run amok, but if you can't even handle python, then I suggest getting a nice non-technical job that won't stress you out too much. I don't even like python all that much, but I would hardly call it any more challenging than, say, Visual Basic.
      • by renoX ( 11677 ) on Wednesday July 27, 2005 @12:41AM (#13173858)
        Well of course if you're used to Perl, OO programming will seem very hard to learn :-)

        For learning OO programming, I'd advise 'Object-Oriented Software Construction' it use Eiffel as its programming language, and is quite old but it is very, very clear about why OO programming makes sense.

        And for me, Python or Ruby (preferably) are better than Perl because those language have a readable syntax by default, in Perl you have to fight the language to produce readable code, thus a big majority of Perl code is just unreadable, barf.
  • 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? Comp
  • by scribblej ( 195445 ) on Tuesday July 26, 2005 @04:18PM (#13170206)
    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?

  • by Anonymous Coward on Tuesday July 26, 2005 @04:18PM (#13170207)
    Larry is my savior.
  • by Rosco P. Coltrane ( 209368 ) on Tuesday July 26, 2005 @04:20PM (#13170230)
    Learning Perl is generally in the top three recommended books for new Perl programmers

    The other two being this one [amazon.com], and this one [amazon.com].
    • by Otter ( 3800 )
      As with "The C Programming Language", "Learning Perl"'s prominence is based more on its historical significance than on its merits as a text compared to its competitors.
      • That's certainly one AC's opinion. Good thing most people don't share your opinion. Otherwise, I wouldn't have a job.
        • Well, actually I think you would have a job. If you were the guy on PerlCast, you have two jobs, a writing job and a consulting (programming/managing) job. If you lose your writing job you still have your consulting job.
  • Nice review (Score:5, Funny)

    by $RANDOMLUSER ( 804576 ) on Tuesday July 26, 2005 @04:22PM (#13170264)
    > s#(.*?)#$1#g;
    But why the cartoon swearing??
  • Hated it (Score:4, Informative)

    by jafac ( 1449 ) on Tuesday July 26, 2005 @04:22PM (#13170266) Homepage
    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.
    • I tend to concur, although Learning Perl Objects, References and Modules is a pretty good read and a good companion to the cookbook.
    • Re:Hated it (Score:3, Informative)

      by PCM2 ( 4486 )
      I sort of concur, though you have to start somewhere just to pick up the syntax of the language. For that, I used Programming Perl (the bigger, more reference-oriented book). Probably the most enlightening one I read was Advanced Perl Programming, [oreilly.com] which has also just been updated. That was the one that made me say, "Ah-haaaaaa, so there's more to this than CGI scripts."
    • I personally absolutely loved Programming Perl (3rd edition), and in fact, it's the book I used to learn Perl, too.

      I also still use it as a reference - finding stuff in there usually takes less time than Googling for it or looking at the manpages. :)

      To each their own, of course, but I think it's not fair to characterise Programming Perl at least as a bad book.
    • I'm reserving Perl as a skill ONLY used when absolutely necessary

      Yeah, so do I. It's also the only language I use day to day :)

      I find that Effective Perl Programming [amazon.com] is a nice "once you know the syntax" book. I don't actually remember what books I learned Perl from (I think I skimmed the Camel and then just read the perldocs), but reading this one in "retrospect" I found a lot to agree with.

    • Sounds like somebody hasn't discovered he power of CPAN!
      • actually, "the power of CPAN" is verboten where I work. I can look shit up in books, but I can't download code. Dumb rules.

        Anyway, I feel kind of guilty for getting modded to 5 for ripping those books, but I thank all the responders for their tips on good perl books.
        • Well apparently people just agree with you. And even though I like Larry Wall (he has a cool story about creating Perl and his talk about Perl 6 is interesting to me), I am inclined to agree with you about Programming Perl at least. There is a lot of fluff in that book.
  • regex (Score:3, Informative)

    by __aahsof7392 ( 588795 ) on Tuesday July 26, 2005 @04:24PM (#13170294)
    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
    • Re:regex (Score:3, Informative)

      by slavemowgli ( 585321 )
      The author just forgot to escape some < and > characters in there, so part of the regexes gets interpreted as HTML.

      And of course, the Slashdot editors didn't catch that, but that's probably hardly surprising...
  • the review (Score:3, Insightful)

    by Amouth ( 879122 ) on Tuesday July 26, 2005 @04:35PM (#13170415)
    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)
    • Re:the review (Score:3, Insightful)

      by chromatic ( 9471 )

      Perhaps you'll like Perl Best Practices [oreilly.com] then.

    • Re:the review (Score:5, Insightful)

      by Tsiangkun ( 746511 ) on Tuesday July 26, 2005 @06:27PM (#13171526) Homepage
      Not trolling here,

      When kids learn to read, they sound out each letter.
      Then readers progress to sounding out each syllable.
      Advanced readers can read in words instead of syllables, and no longer sound out each piece.
      Really advanced kids read in phrases and sentences.

      Perl is like learning to read two languages at once. One needs to develop proficiency in regular expressions, and the Perl language itself to be able to read Perl script effectively.

      Most of what people bitch about is the regular expressions, and not the Perl itself. Yes, the syntax might be tweaked on the Perl implementation of regular expressions, but if you understand them well in another form, it's not mind boggling. The tight integration of regular expression and a programming language leads to elegant problem solving methods, and I appreciate them the same way I appreciate a koan.

      Once someone can read and write, they seldom use the same expressions as someone new to a language. This only further alienates newbies and adds to the theory that Perl is unreadable line noise. Perl is Perl, and one either gets it or they don't. No amount of formatting will make it any clearer if the reader only knows baby speak for either regular expressions or the Perl language.
    • book that beats people into submission so that they make READABLE perl

      One of the key issues repeatedly addressed in this book (and our courses [stonehenge.com]) is readable and maintainable Perl.

      We often talk about "the maintenance programmer". As in, "you, three months/weeks/hours from now, when you can't remember what the hell you wrote", and how to write for "that" person.

      Believe me, I have a vested interest in removing the "Perl is unreadable/unmaintable" meme. It shall die!

    • That's strange... 99% of the perl I look at makes me wish I were dead. We should get together...
  • by onlyjoking ( 536550 ) on Tuesday July 26, 2005 @04:55PM (#13170642)

    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.

    • by merlyn ( 9918 ) on Tuesday July 26, 2005 @06:33PM (#13171572) Homepage Journal
      Actually, can I be honest?

      We didn't really have 5.8's differences in mind. However, we made sure that the exercises were not invalidated by 5.8.

      So yeah, you got us. It's a marketing ploy.

      However, we did do more than "rearrange" things. We're constantly updating our Llama class [stonehenge.com], and the latest changes were indeed dragged back into this book. So, you've got the best of an already good class, as updated by people that are teaching it every week.

  • Sounds interesting. Does anyone know whether there's gonna be a 4th edition of Programming Perl (the Camel Book) anytime soon, too?
  • by Craig Maloney ( 1104 ) * on Tuesday July 26, 2005 @04:59PM (#13170695) Homepage
    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 te
    • From what I've been hearing from hiring managers, the jobs for Perl [perl.org] are largely going unfilled, because since the dot-bomb, many good Perl hackers jumped ship early and are now underemployed in crappy other-language jobs.

      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.

    • CPAN - take a look (Score:3, Insightful)

      by oo_waratah ( 699830 )
      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.
    • 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).

      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 /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.
    • Erm.... I just started learning perl this week to administer active directory.

      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.

    • ...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.

      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 joke, I joke. I have Visual Python!
  • ...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.
  • I am learning Perl using Beginning Perl [perl.org]
    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).
  • "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.

As the trials of life continue to take their toll, remember that there is always a future in Computer Maintenance. -- National Lampoon, "Deteriorata"

Working...