Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

How best to learn OO Perl?

by rose (Beadle)
on Jun 30, 2006 at 11:47 UTC ( [id://558556]=perlquestion: print w/replies, xml ) Need Help??

rose has asked for the wisdom of the Perl Monks concerning the following question:

Great Monks,

I want to learn OO Perl. Can you Provide a link/example to learn Class, Packages, Constructors, Destructors, Inheritance, Base Classing, Accessors, Mutators, Class Context, Object Context Methods.

It would be very helpfull if you provide the same.

Thanks in Advance!!!
Rose

2006-06-30 Retitled by planetscape, as per Monastery guidelines

( keep:0 edit:13 reap:0 )

Original title: 'OO Perl'

Replies are listed 'Best First'.
Re: How best to learn OO Perl?
by jdtoronto (Prior) on Jun 30, 2006 at 12:05 UTC
    Try perltoot, but you will find the best references are some books, I personally like "Object Oriented Perl" by Damian Conway thedamian.

    jdtoronto

      I'll second the recommendation for Damian's book. It is the best book covering this topic, IMHO.

      -albert

Re: How best to learn OO Perl?
by davorg (Chancellor) on Jun 30, 2006 at 12:26 UTC
Re: How best to learn OO Perl?
by derby (Abbot) on Jun 30, 2006 at 12:21 UTC
Re: How best to learn OO Perl?
by borisz (Canon) on Jun 30, 2006 at 12:24 UTC
Re: How best to learn OO Perl?
by merlyn (Sage) on Jun 30, 2006 at 16:30 UTC
      Well, "Intermediate Perl" is not one of my favourites sadly merlyn, I am glad you didn't mention "Learning Perl Objects, References and Modules"! Whilst I like your columns I have found that one in particular difficult to follow. However, "Learning Perl" is never far away, it is on the shelf right behind me.

      I taught myself OOPerl from "learning Perl Objects" but didn't understand it and become comfortable with it until "Object Oriented Perl", I am also a fan of "Perl Best Practices" ( thedamian ) and "Higher Order Perl" ( dominus ).

      But why does nobody mention "Effective Perl Programming" (Hall and Schwarz 1998), it is still a handy reference with some good ideas, and the 20 pages on Object Oriented Programming forms a conconcise introduction to the topic.

      jdtoronto

      And the fact that you're one of the authors isn't influencing your recommendation :-)

      Jokes aside, I would second merlyn's reccomendation of his book as a good way to learn OO Perl, followed by Damian's OO Perl book, which goes into a lot more detail

      TStanley
      --------
      War is an ugly thing, but not the ugliest of things. The decayed and degraded state of moral and patriotic feeling which thinks that “nothing is worth war” is much worse. The person who has nothing for which he is willing to fight, nothing which is more important than his own personal safety, is a miserable creature and has no chance of being free unless made and kept so by the exertions of better men than himself. -- John Stuart Mill
Re: How best to learn OO Perl?
by swampyankee (Parson) on Jun 30, 2006 at 16:09 UTC
Re: How best to learn OO Perl?
by nothingmuch (Priest) on Jul 03, 2006 at 00:47 UTC
    You can look at Moose, which makes OO writing pretty easy.

    A class is declared as:

    package Class::Name;
    a package is a symbol table namespace, in which symbols are stored. Every class has it's own package which it lives in.

    Constructors are anything which calls bless, you should read perltoot to get a handle on that, but if you want to ignore that Moose will provide a default constructor named new for you.

    Every class gets DESTROY called right before it's garbage collected. You can hook to that. C<Moose> let's you specify sub DEMOLISH which does not have to call the super class's destructors.

    Inheritence is controlled with the special variable @ISA in every package, which contains a list of base classes. YOu can use the extends keyword in Moose to clean that up a bit.

    Accessors are autogenerated for you when you use attributes, like:

    has name => ( is => "rw", # what accessor to generate, can also be wo or ro );

    I don't know what you mean by contexts - that's a very general term.

    -nuffin
    zz zZ Z Z #!perl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://558556]
Approved by ciderpunx
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-03-29 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found