Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Trying to understand Perl Objects

by TGI (Parson)
on Apr 06, 2009 at 21:03 UTC ( #755857=note: print w/replies, xml ) Need Help??

in reply to Trying to understand Perl Objects

OOP in Perl has a very strong DIY flavor. As a result, there are all sorts of ways to build your objects in Perl: classical methods with blessed hash or array refs, inside out objects, and even more exotic XS based objects.

You can do all the work yourself each time you write a new OOP module and implement all your accessors and mutators, type validation, and so forth manually. Or you can use one of the many modules to help automate the process.

I have found that two ways of generating object code work well for me.

For dirt simple objects that are used to contain some data and bind a few methods to the data structure, Class::Struct does a very nice job. It is very limited and somewhat brain-dead (eg. can't use it in subclasses), but for very, very simple tasks, it reduces a lot of busy-work, and I can understand exactly what it does.

For anything with more than the most minimal demands, Moose is the way to go. It provides much of the goodness we will see with Perl6 objects. I've used it for a few projects now, and it is really quite amazing.

For an example of why Moose is so great see the Moose Unsweetened document for a comparison of manual and Moose object code.

Perl 6 is not even fully specified, and is certainly not ready for prime time. The Parrot VM just released version 1.0 which provides a stable API for language implementors, but is still not 100% ready for production use--that will come in 2.0. Both projects are cruising along, but both are far from being ready for production use. If you want perl 6 oo, with roles and type checking, etc. Moose is the best way to get it now.

TGI says moo

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://755857]
[marto]: that is to say, to the best of my knowledge, they never did.
[marto]: they have a commercial product called perlapp
[mark4]: Do you h=know how I can get pp.exe? Is there a module I can install that includes this?
[marto]: I always found Strawberry Perl on windows to be a much better environment, made life much easier
[marto]: pp. install it like you would any other module
[marto]: it probably exists in one of the PPM repositories
[marto]: failing that see the README
[mark4]: I installed "PAR" from the ppm install window. pp.exe. did not show up.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2018-01-19 14:15 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (218 votes). Check out past polls.