Slashdot Mirror


Learning Perl Objects, References & Modules

honestpuck writes "In the world of Perl there was once only the 'camel book,' held in perhaps as much reverence as 'K & R' among C programmers. It certainly appealed to roughly the same audience, those who wanted a short, sharp introduction to a programming language. It was with a problem that needed solving and a copy of the camel book that I started as a Perl programmer." Read on for honestpuck's review of another book he regards at least as highly. Learning Perl Objects, References & Modules author Randal L. Schwartz with Tom Phoenix pages 205 publisher O'Reilly rating 9.9 - Cannot find a fault reviewer Tony Williams ISBN 0596004788 summary Perfect book for taking your Perl skills to the next level

Then for those that wanted a introduction to Perl and programming Randal L. Schwartz wrote Learning Perl, a book that has arguably become the definitive textbook for teaching Perl. The one weakness was that it left off before really getting to the guts of building large, complex projects in Perl. It did not cover classes, objects, breaking your code up into pieces or the more arcane aspects of variables, references. For this we had to resort to the last few chapters of the 'camel book' and I, for one, have never really been totally comfortable at this end of the language; when I'm reading someone else's code it might take a couple of reads to fully understand the process.

Now this weakness has been well and truly addressed. Schwartz, with Tom Phoenix, has written "Learning Perl Objects, References & Modules", a volume that takes the same steady approach to teaching you the more advanced topics as the earlier 'Learning Perl'. Schwartz has spent the years since writing 'Learning Perl' teaching and writing. You can tell, this is a superbly written book, not that 'Learning Perl' wasn't well written; it's just that this volume is far better.

The Guts

The book starts with a chapter on building larger programs that covers @INC, eval, do and require before discussing packages and scope. It then has several chapters on references that explains in well understandable fashion and increasing complexity all the ins and outs of references including dereferencing, nested references, references to subroutines and references to anonymous data before a final chapter on references that gives you some incredibly useful tricks such as sorting and recursively defining complex data.

The book continues with three chapters that give you a solid grounding in Perl objects. Here Schwartz has assumed that you know at least a little about object oriented programming, some may feel the need for more explanation of concepts might be required, but if you've had any experience in OOP before then the clear examples and descriptions here are probably all you want.

Modules are not as well covered, with only a single chapter, but it is hard to think of anything left out, it covers using them and building your own so well that it left me wondering what all the fuss was about, "seems obvious to me." The book concludes with chapters on building a distribution out of your module, testing it using make test (with Test::Harness), Test::Simple and Test::More before a chapter telling you how to contribute to CPAN.

Each chapter of the book concludes with a number of small exercises, designed to be done in just a few minutes, that cement the learning of the previous chapter. The answers to these are at the end of the book.

Conclusion

Once I'd finished I felt I had a much more solid grounding in Perl, certainly I was much better able to understand another programmer's code that dealt with such things as subroutine references and some complex data structures. While the subject matter of this book is almost entirely covered in 'Programming Perl' the tutorial aspects of this book made it much easier going. The style would be familiar to anyone who has read 'Learning Perl', light without being frivolous and extremely well written, Schwartz seems a master at reducing complexity to manageable bites.

This book is deceptively easy to follow, each new idea built onto earlier ones, each new language concept introduced in an easy manner. The writing is excellent, it's hard to explain why I appreciated it so much. That may be the reason, the writing isn't forced or heavy or too light or obvious. It just allows the solid material of the book to shine through. Go to the ubiquitous O'Reilly website and grab the example chapter (the site also has a few Errata, the Table of Contents and the code from the book) and give it a look.

I think this may well become a classic, I may well in ten years time talk of Schwartz's books with the same awe I now talk of Brian Kernighan's. I'll certainly eagerly await his next book and keep this one close until it comes. Oh, and Randal, how about 'Software Tools for Perl Programmers'?

You can purchase Learning Perl Objects, References & Modules from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

10 of 158 comments (clear)

  1. Readability.... by fiftyfly · · Score: 5, Funny

    Man I can't read my own perl, I can't imagine buying a book simply for the pleasure of reading someone else's

    --
    "Sanity is not statistical", George Orwell, "1984"
    1. Re:Readability.... by Frymaster · · Score: 4, Funny
      hey! there's some perl that's actually quite readable (and even poetic). witness the "black perl" script:

      BEFOREHAND: close door, each window & exit; wait until time.
      open spell book, study, read ( scan, select, tell us );
      write it, print the hex while each watches, reverse its length, write again;
      kill spiders, pop them, chop, split, kill them.
      unlink arms, shift, wait & listen ( listening, wait ),
      sort the flock ( then, warn the "goats" & kill the "sheep" );
      kill them, dump qualms, shift moralities, values aside, each one; die sheep ! die to reverse the system you accept ( reject, respect );
      next step, kill the next sacrifice, each sacrifice, wait, redo ritual until "all the spirits are pleased";
      do it ( "as they say" ).
      do it ( *everyone***must***participate***in***forbidden**s *e*x*). return last victim; package body;
      exit crypt ( time, times & "half a time" ) & close it, select ( quickly ) & warn your next victim;
      AFTERWARDS: tell nobody.
      wait, wait until time;
      wait until next year, next decade;
      sleep, sleep, die yourself,
      die at last
      and it actually parses.

      note: this script is for entertainment purposes only and is not meant as an endoresement of human sacrafise, real or virtual.

  2. It's the alpaca book by M.+Silver · · Score: 2, Funny

    ... for those of us who can never remember the titles, only the critters.

    --

    Slashdot's token middle-aged housewife
    1. Re:It's the alpaca book by smittyoneeach · · Score: 2, Funny

      Possible /. poll:

      Favorite animal not used on an O'Reilly cover.

      My vote: tribble.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  3. 9.9? by mopslik · · Score: 5, Funny

    Rating: 9.9 - Cannot find a fault

    Obviously, the review was calculated using an early Pentium.

  4. well! by Anonymous Coward · · Score: 1, Funny

    how about putting a spoiler warning! you practically gave away the ending!

    You did the author a huge disservice.

  5. My advice by Anonymous Coward · · Score: 1, Funny

    Wait for the movie.

    I heard O'Reilly got Tom Cruise to be in it.

  6. Re:What C programmers hold the K&R book in rev by Anonymous Coward · · Score: 1, Funny

    Don't buy it. It's a cheap Chinese knock-off of Deitel and Deitel, whom I wholeheartedly recommend.

  7. Re:What C programmers hold the K&R book in rev by ggruschow · · Score: 4, Funny
    I'm thinking of getting myself a copy of one of the C++ specs to help me answer the really obscure questions. Does someone recommend a particular spec (e.g., ANSI, ISO)?

    Actually, this pretty much solved all my obscure or arcane C++ questions. In fact, while referring to that I haven't once had trouble figuring out if I was implicitly causing a conversion which caused a deep copy which in turn caused a memory leak since.

    Of course, "Why did my program just pause for a 1/10th of a second, and how can I avoid that?" comes up more often now.

  8. Re:Perl is teh sux0r by gantrep · · Score: 1, Funny

    Because it has lots of k3wl functions. Wow, system, passthru, shell_exec and bactics? So many choices of how I can execute my perl scripts!!