Learning Perl Objects, References & Modules 158
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.
Readability.... (Score:5, Funny)
Re:Readability.... (Score:5, Insightful)
For instance, in Java "String foo;" and in perl "$foo". Now, later in the code, if I see "$foo" in my perl code, I know immediatly that I'm dealing with a scalar, or %foo is a hash, whereas in most other languages I have to either remember the variable declarations or go back and find the variable declaration in the file.
Also, I think alot the supposed unreadability of perl has to do with regex. Since regex is such a basic part of perl, it gets used alot and when you come across "$_ =~ s/^([^ ]*) *([^ ]*)/$2 $1/;" you may attribute the mess of characters to perl when in fact, most of the mess is regex, which exists in many languages.
This is not to say that I haven't see lots of ugly code, perl or otherwise but I don't think perl is really any more difficult to read than other languages.
Re:Readability.... (Score:1)
Oh no, I'm going to get moderated down, but honestly, I don't mean this as a troll.
This got posted to a thread I was following once:
Re:Readability.... (Score:2)
Re:Readability.... (Score:1)
>I know immediatly that I'm dealing with a scalar
And this could be any one of:
- an integer
- a real number
- a string
- a reference to an array
- a reference to a blessed array
- a reference to a hash
- a reference to a blessed hash
- a reference to a scalar
- a reference to a blessed scalar
Well thank goodness that $ is there so that it's so easy to tell what type of data the variable holds.
I disagree that regex's are the reason some Perl code is har
Re:Readability.... (Score:1)
Re:Readability.... (Score:5, Insightful)
The difficulty lies in the fact that it is possible to obfuscate Perl to such a degree, and that so many Perl hackers seem to think more obfuscation makes them look like a better programmer. There's even a contect that rewards this kind of thing.
If you want to write good, maintainable code, you can do it in Perl just as well as any other language. If you want to write an obfuscated mess, the same holds true. Sure, writing obfuscated Perl may make you feel more manly or whatever in the short term, but it won't help you keep your job when you can't read what you've written 6 months later.
Re:Readability.... (Score:2, Insightful)
But perl's mindset from what I can tell is power through brevity and flexibility. Going from it to Java is tortuous. So many words to type!!! But the
Perl Readability (Score:2)
This shouldn't be confusing. How about foo[ bar ][ foo2 ]? Indexing into a 2-dimensional array in C. Your example is the same except that we index associative arrays.
Re:Readability.... (Score:2)
Then if there's something Perl-like that's more efficient, or that can't be done with C-like syntax, I comment it up.
So it IS possible to write readable Perl. You just have to think about doing it WHILE you're coding.
wbs.
Strange... (Score:1)
in other languages in order to see the difference?
I can think of at least 2 languages that are
50 miles simpler to read.
But syntax is not a major issue anyway. The
main issue is the capabilities of the language.
Apparently, those who speak on issues of syntax
and general look-and-feel have no knowledge
to talk about the more techincal issues. So here
here you have it: 1000 posts about how the
language "feels", and we are going to skip
the hard technical issues which yo
Re:Strange... (Score:1)
Oh, and what's better? Java? C#? C++? COBOL?
You are incorrect in your assumption about tech knowledge as it relates to conversation about look and feel. Both subjects should be important to those who write code for a living.
Tech issues? Which ones are important here? Please speak up and share your wisdom.
wbs.
Re:Strange... (Score:1)
compared to Lisp, Basic, and Rexx .
You imply that you make your living in programming and
that the "feel" of a language is important. Why?
As a programmer you should know that the "feel"
of the language is probably the least of your
worries. You know what other issues are important,
but since you have to ask, and I don't feel
like embarking on 3000 word essay, lets only
mention that the capabilities of the language
is more important than "feel", yes, and we are not
fagots. W
Hear Hear! (Score:2)
On the POPFile project I've done everything I can to avoid Perl's temptations into obscurity by writing clear code. Amazingly I've been critized by monoric readers of the code that I could have done things with less "space" (i.e. using less screen real estate). People like that know nothing about maintenance of code and should just bu
Re:Hear Hear! (Score:2)
Hey, you shouldn't discriminate against people with Mono. After all, it's a kissing bug, baby!
Re:Readability.... (Score:2)
NOTE: I had actually written out a list of them here, and there are about 30 of them, but
"Lameness filter encountered. Post aborted!
Reason: Please use fewer 'junk' characters."
Which kinda makes my point in a roundabout way.
I mean, seriously. These are all valid variables in Perl and have specific meanings. But they aren't exactly readable. Some of them (like $| and $_) you probably already know, but the Perl brevity /
Re:Readability.... (Score:1)
I totally agree with you. Even in the case of regexps, the /x modifier is available and you can use it to add spaces and even comments to enhance your code's readability. So again, it boils down to the programmer and his/her preferred style.
The difficulty lies in the fact that it is possible to obfuscate Perl to such a d
Re:Readability.... (Score:5, Funny)
BEFOREHAND: close door, each window & exit; wait until time.s *e*x*).
return last victim; package body;
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**
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.
It's the alpaca book (Score:3, Funny)
Re:It's the alpaca book (Score:3, Funny)
Favorite animal not used on an O'Reilly cover.
My vote: tribble.
9.9? (Score:5, Funny)
Rating: 9.9 - Cannot find a fault
Obviously, the review was calculated using an early Pentium [maa.org].
Re:9.9? (Score:1)
Why are these lame jokes becoming popular again? In capitalist Slashdot, early Pentium calculates YOU!
(stares blank-faced at equally lame Yakov imitation)
It's like the square root of a million -- some things we'll just never know.
me too (Score:3, Interesting)
how else would one want to learn perl?
Re:me too (Score:1)
Re:me too (Score:2)
well! (Score:1, Funny)
You did the author a huge disservice.
HOORAY!! (Score:2)
This book - two thumbs down (Score:5, Insightful)
Which while some may enjoy cute little stories about the time the guy was up all night to meet a deadline, some of us read technical books to learn or enhance technical skills.
This is so far from K&R it's sacrelige to even make the comparison. Shame on you.
Re:This book - two thumbs down (Score:1, Offtopic)
Re:This book - two thumbs down (Score:2)
Mr. Schwartz does seem to know how to milk those cash camels, though!
Re:This book - two thumbs down (Score:2)
Are you prepared to show evidence?
Re:This book - two thumbs down (Score:2)
Re:This book - two thumbs down (Score:1)
Still haven't found one at page 76.
You did read the book didn't you?????
Re:This book - two thumbs down (Score:2)
Um, the reviewer was comparing K&R to "Programming Perl" -- a/k/a "The Camel Book" -- not to the book being reviewed. Which is a fair comparison in that both books pretty much define the language in question.
Re:This book - two thumbs down (Score:1)
Re:This book - two thumbs down (Score:1)
Just because I think that you and the rest of your groupthink idiot ilk are laughable and worthy of ridicule, doesn't mean that you need discount everything I say.
You're like a second grader with his hands over his ears screaming "LALALALAL I CANT HEAR YOU".
Go fuck yourself, put me on your foes list, and dont bother reading my posts.
Thank you for your (no doubt worthless) time.
Re:This book - two thumbs down (Score:1)
"Stratjakt is a known Communist. Check out his other work."
You are suffering from the Dubyaitis: everything's black and white, good and evil, trolling and "serious" slashdot use. The world doesn't work like that, my friend. The world is not black and white. The world is shades of gray.
Re:This book - two thumbs down (Score:1)
Black and white.
What C programmers hold the K&R book in revere (Score:5, Interesting)
[Aside: The book I use most often is Stroustrup's C++ Second Edition, which in itself is rather vague and outdated wrt the details I need to know most often these days. 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)?]
Re:What C programmers hold the K&R book in rev (Score:5, Insightful)
I couldn't disagree more. I learned C from the original K&R book. It was well organized, clear, and consise. The Camel book, on the other hand, often seemed like concepts on page n relied on concepts introduced on page n+1. I found that no matter how much I programmed in Perl (about a year's worth of time) and no matter how much I used the Camel book, I could never find what I was looking for without a massive search.
Re:What C programmers hold the K&R book in rev (Score:2)
To be fair, a sprawling language like Perl needs a sprawling reference, and the Camel book does a decent job of it.
Personally, I don't often refer to K&R, but that's because C is a simple language that you can learn in its entirety without too much effort. Who truly knows all of Perl? Or C++ or COBOL, to mention two other giant languages? A small per
Re:What C programmers hold the K&R book in rev (Score:4, Funny)
Actually, this [sun.com] 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.
LOL (Score:1)
Re:What C programmers hold the K&R book in rev (Score:2)
Re:What C programmers hold the K&R book in rev (Score:1, Funny)
Recommend Perl: The Complete Reference (Score:1)
Re:Recommend Perl: The Complete Reference (Score:1)
Once you've read the camel book, you are truly "over the hump", and can really start to program in Perl.
Try perldocs (Score:5, Insightful)
At some point you have to put the books down and start programming if you truly want to master the language. After the Camel book is probably a good time to start, with references to the Cookbook when needed. For other info, the perldocs are recommended.
Re:Try perldocs (Score:4, Insightful)
Having said that, the Camel book is probably the single most useful programming book I have ever read. I bought my copy 6 or so years ago (right after the 2nd edition came out) and I still use it to this day. It is unusual in that it not only allows one to pick up the language quickly and easily, but is concise enough to be used as a quick reference that is often more handy than the perldocs.
It may be that I had already been programming Perl for too long before the other books came out, but I was never able to find anything really useful at all from them.
Re:Try perldocs (Score:1)
I would definately recommend this book to the developers who are at that stage of their development. It's a useful tutorial style book for
Re:Try perldocs (Score:2)
I know that I'm stating the obvious, but nothing in electronic media comes close to replacing printed manuals.
Damien Conway's "Object Oriented Perl" ? (Score:5, Interesting)
Re:Damien Conway's "Object Oriented Perl" ? (Score:2, Informative)
Of course then I might go back and reread the Conway just to see if it makes more sense.
So for me I prefer this one. Bu
Re:Damien Conway's "Object Oriented Perl" ? (Score:3, Informative)
Re:Damien Conway's "Object Oriented Perl" ? (Score:2, Interesting)
Re:Damien Conway's "Object Oriented Perl" ? (Score:3, Informative)
I'm not bagging on Damiens book at all - it just started above my head.
As for the poeple baggin on Randals book, my guess is is started at too low a level for them, so they think its useless - completly forgetting that t
Re:Damien Conway's "Object Oriented Perl" ? (Score:3, Informative)
Also, the OO part of the Alpaca book is only a portion of the text, and is necessarily light in coverage. The point of the Alpaca is to get you to understand most 100 to 10,000 lin
Re:Damien Conway's "Object Oriented Perl" ? (Score:2)
Damian's book is great, but a good comparison would be that Learning Perl is to the Camel what Learning Perl Objects, References and Modules is to Damian's book. Both of my tutorial books are tutorial in design, based on years of classroom experience in teaching these subjects. Both of the other books are reference in design.
Hi, Randal,
The Gecko book was very important to me when I made the big step from Perl as a replacement for awk scripts to Perl as an application development tool, around 1997 (the
Re:Damien Conway's "Object Oriented Perl" ? (Score:2)
It's still selling because it still sells. O'Reilly doesn't drop books that still make a profit, even when they're outdated.
I'd consider the Alpaca plus Damian's book to be a complete replacement of everything that the Jaguar had
Re:Damien Conway's "Object Oriented Perl" ? (Score:1)
Just want to add that even after using perl for a few years, his beginning 1/3 chapters alone are worth the price of the book. It's a refresher on the fundamentals of perl, with good, funny examples of just about 90% of everything I knew. Even lots that I *didn't* know, with me going "Wow, I didn't know you can do that!". Heck, most of the important stuff from the Camel book is summarised here.
The last 2/3 that deals with OOP is just g
O'Reilly website truly ubiquitous? (Score:1)
Rating (Score:3, Interesting)
Re:Rating (Score:1)
Sounds like my employee review.
"I'm only giving you an 85%. This way, I can give you an 88% next year, and since you're 'improving' you get a raise."
If at first you give something 100%, any other than 100% is BAD.
Re:Rating (Score:1)
books (Score:4, Interesting)
The idea that you can do a PPM search for a module via CPAN based on your need, download it, and have it's docs integrated into the centralized documentation is great. perlfunc, perlre, perlobj, etc are a bit arcane but with a little elbow grease and a good editor (SlickEdit!), you figure things out pretty quick.
Re:books (Score:2)
Re:books (Score:1)
BUTTTTTTTTTTTTTTTTTTTTTTTTTT, just before I read your post demanding that it be knocked down I was thinking that someone should start a new subject on "Learning programming through books - pros and cons" or some such thing. I keep noticing these statements from people who claim that they don't need to read books, and seem to be proud of it. Personally I think that's nuts. But there certainly do seem to be a number of people of that persuasion. Much of it seems
Re:books (Score:3, Interesting)
I think the books vs no-books is based in part on age, but only because age relates to school, which is book oriented. Those who have been out of school a while, or never went to college, may find through experience that skipping books and going straight for built-in docs (or trial and error) works for them.
Younger folks tend to prefer books especially if they just finished, or are still in, college, for obvious reasons.
I see the Youthful Bravado angle, and
Re:books (Score:2)
Perl without the Camels? (Score:3, Insightful)
Re:Perl without the Camels? (Score:1)
My advice (Score:1, Funny)
I heard O'Reilly got Tom Cruise to be in it.
I have it too (Score:5, Informative)
Basically, if your introduction to Perl was via "Learning Perl" then this is probably a great next step. I went through the Camel book and the Perl cookbook instead, and find that this one does not give all that much more information as I would have liked. This is not strange; the authors explicitly say in the preface that this is the companion book to "Learning Perl".
On the upside, it does give a good deal of useful snippets of info, and it manages to give clear explanations for some stuff that is otherwise quite opaque; the way it explains the Perl object model, for example is much clearer to me than the treatment given in the Camel book.
I would have given it 7.5-8 rather than the extreme score the reviewer gave.
Half way through (Score:5, Insightful)
So, half way through, I give it two thumbs up. My Perl programming has just gotten a lot more sophisticated. Maybe I was dense to begin with but any step up is something I'm happy about.
As far as those nutty complaints about O'Reilly lingering at the bottom of this thread all I can say is that they've found their proper place.
Re:Half way through (Score:2)
I wouldn't recommend it to anybody. The way it makes you put different objects in different files/modules is so counter to Perl's scripting heritage that a good procedural/reusability-based outlook will get a lot more traction than this OO mess, at least 'til Perl 6.
Re:Half way through (Score:3, Informative)
Different classes can be defined in the same file, no problem - just make a package declaration to begin each new one.
Having said that, I've never wanted to actually have more than one class in a file. Sure, OO is counter to 'Perl's scripting heritage', but so what? There's a reason that much of the good stuff on CPAN is written in an OO style.
Re:Half way through (Score:2)
Perl 5's OO model is really, really painful.
On the other hand, I adore it. I find it intuitive, it does just what I want it to do, and gets out of the way when I need it to. Like I tell my children, everybody is differrent.
honestpuck is a review machine (Score:2)
Re:honestpuck is a review machine (Score:1)
Re:honestpuck is a review machine (Score:2)
While it sometimes seems as if I'm paying the grocery bills for 10 people, no, there's only one of me.
Actually, the last three reviews published here were written over about 6 to 8 weeks and submitted to Slashdot over a 5 week period. The books were read over an even longer period, it's just that I often write reviews in a surge of two or three at a time. I'm also usually writing a couple of reviews at once as I always re-read a book after a first draft of the review.
Tony 'honestpuck' Williams
Randal Schwartz (the writer) (Score:5, Informative)
He's written well over 3,000 posts on Perl [perlmonks.org] over at PerlMonks.org [perlmonks.org].
Randal will be at.... (Score:2, Informative)
Bob
wow (Score:1)
OOP in Perl is a Bad Thing (Score:1, Interesting)
This is so common in Perl (and other languages). Especially with contractors, for some reason. They come in, write expert level code, using all the secret codes and handshakes, then the average schmucks in the cube farms cannot maintain the code.
Re:OOP in Perl is a Bad Thing (Score:5, Informative)
OO in Perl is not hard, sure its syntax is a bit different but the concepts are the same and there are multiple books (like this one), online resources such as this [perlmonks.org], and not to mention the existance of 4 (not 1 or 2 but 4) tutorials on OO in perl that come with the documentation. If people don't expect their "schmucks in the cube farm" to be skilled in a language then its no wonder that our jobs are going to India!
Re:OOP in Perl is a Bad Thing (Score:1)
Re:OOP in Perl is a Bad Thing (Score:2)
Re:OOP in Perl is a Bad Thing (Score:2)
Somebody once complained to me that I used obscure constructs in C like the ternary operator (a ? b : c). Obscure C?
One could argue that the reason expert programmers are hired is so that they will "write expert level code".
The Emperor's New Perl Book (Score:1)
So, I will play the part of the small child in the story of "T
Re:The Emperor's New Perl Book (Score:1)
Must-have if you enjoyed "Learning Perl" (Score:1)
Even though I already have Conway's book I still picked up Schwartz's since I need a quick refresher and Schwartz has a knack for being clear, concise and congenial for the real-world programmer.
Definitely consider picking it up if your work
Short? (Score:1)
I like the Camel Book, but short it ain't. The Third Edition is 1067 pages. For that much paper you can have K&R2 and Advanced Programming in the UNIX Environment, or the ISO C spec and a pretty complete POSIX reference, or almost half of the GCC manpage.
C# or Java (Score:1)
Re:Perl is teh sux0r (Score:1, Insightful)
Why would they move to a less capable language?
(and I'm not even a Perl guy)
Re:Perl is teh sux0r (Score:1, Funny)
38% off at bookpool! (Score:1)
Our Price: $21.50
You Save: $13.45 (38% Off)
Re:Bookpool? (Score:1)
You'd rather support Amazon and their stupid claims that "We invented the concept of storing a credit card so you can check out faster?"
I think not.
Re:"Review"? (Score:1)
Next time, post a ninja-link to goatse.cx [goatse.cx] -- at least some guy's bloody asshole is less disgusting that watching b-flack and j-lo trying to act!
Re:Can somebody tell me where to find 'K & R' (Score:1)
http://www.amazon.com/exec/obidos/tg/detail/-/0
Re:Can somebody tell me where to find 'K & R' (Score:1)
by Brian W. Kernighan, Dennis Ritchie, Dennis M. Ritchie
For some reason the link doesnt work