Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How best to learn OO Perl?

by nothingmuch (Priest)
on Jul 03, 2006 at 00:47 UTC ( #558909=note: print w/ replies, xml ) Need Help??


in reply to How best to learn OO Perl?

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


Comment on Re: How best to learn OO Perl?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://558909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-11-28 17:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (199 votes), past polls