How can I get up to speed about Perl's latest object-oriented capabilities? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this questionI have not done Perl for about 8 years and now I'm going into project that's heavily utilizing object-oriented Perl so I need to resharpen my Perl skills and 开发者_Go百科do it quickly. During these past years I mainly did all sorts of Java development and some PHP. I'm very good at OO and I'm not a novice programmer by any remote extent.
So here comes the question: what are the best resources/sites/practices/ways/books you guys can recommend to pick up on my rusty Perl skills and learn Perl "the new way"? Your suggestions will be much appreciated.
P.S. I did researched some previous answers. I want to emphasize that I'm not looking for novice book/resource (syntax, core principals, etc) but specifically ones that cover OOP capabilities that weren't there when I was programming in Perl (or I may overlooked it at that time)
P.P.S. Thanks to everyone for their suggestions and tips. After some consideration I went with @MBO answer since it's first mentioning Moose which I really like so far.
I don't write Perl code at this time (currently I work in other languages), but I read from time to time this site: http://www.modernperlbooks.com/mt/. Also check Moose for new way of defining objects in Perl
The book "Higher order Perl" might be of interest for you. Best of all - it's free.
Well, first of all Higher-Order Perl is really good, but it's about functional programming, not objects.
Perl Best Practices is an excellent book, but it has limitations, and one of them is that Conway recommends using his own Class::Std module to do inside-out objects, and the general consensus seems to be (1) that if you're going to do inside-out objects, Object::InsideOut and Class::InsideOut are better ways to do it (2) and anyway, using "Moose" based objects is a better way to go.
This illustrates what is probably the major difference between the Java and Perl world: There's rarely one standard way of doing anything with Perl. Starting as someone who feels comfortable with objects in another language, I would guess that the most interesting thing about Conway's now slightly dated Object Oriented Perl is watching him gradually develop different ways of adding OOP features you've been taking for granted.
I like the basic blessed-hash style of Perl OOP myself, but you need to understand that it's encapsulation is really weak, and that while method-inheritance works, there's typically no data-inheritance. There are also some rather perlish tricks in wide use, such as automatically generating accessors using an AUTOLOAD
routine.
As for what you can read on the subject, don't neglect the on-line documentation that comes with Perl: perldoc. Note the "Tutorials" section at the top. If you're rusty on Perl's references and data structures, read the first two: perldoc perlreftut and perldoc perldsc. A little down the list, you'll see multiple OOP tutorials. These are largely about simple href-based objects, though there are some serious oddities in there, such as Tom Christiansen's scheme for closure-based objects down at the bottom of: perldoc perltoot
If you're interested in some of the newer ways people do things, you might want to start with Moose which is supposed to be the closest you can get to perl6 objects while still writing perl5 code. By the way: ignore the word "postmodern" there, it's a silly joke that doesn't make any sense.
If you're interested in inside-out objects (which have bullet proof encapsulation, but are perhaps a little annoying to debug-- you can't just use Data::Dumper on the object to get it's status), I'd suggest starting with this perl5 wiki page.
Check out:
Perl Best Practices - nice collection of suggested best practices. Even if you don't adopt them, the discussion of the reasoning behind the suggestions is valuable.
Perl Testing: A Developer's Notebook - Provides excellent coverage of Perl's testing capabilities.
Object Oriented Perl - An excellent book about how to use and abuse the Perl's object system. This book is a bit dated. It predates inside out objects (whose time has come and gone) and Moose, both important developments in OOP. If you have a large body of older OO Perl to maintain, this book may well come in handy.
PerlMonks - A very handy Perl focused site with a very generous and collegial tone. A good place to go for help and feedback. Its been in operation for years, so there is also a massive archive of posts.
Use Perl::Critic. Read about Moose and MooseX::Declare. Try Padre. Read Perl Iron Man Planet aggregator.
If you can use Moose
then that is the best way to go (IMHO).
There is a book available: Moose. A postmodern object system for Perl 5
The book is the printed version of the excellent online Moose::Manual
/I3az/
精彩评论