in reply to kind of effort required for learning OO perl ?!

Hi Anon Monk.

For some perspective, note that there are really 2 schools of thought regarding object oriented programming with Perl 5.

  1. The first is that you should follow the old, spartan, and fast way of using blessed hash refs. This is what's described in the perlboot and perltoot tutorials. This is the bare-bones old-school way of doing OO Perl 5. In the event of explosive decompression, please note that your seat cushion can be used as a flotation device.
  2. The other school of thought is to use modern, more advanced, much easier to use, but slightly slower technology. The advice here is to use Moose. Moose provides features somewhat similar to Perl 6 OO.

Before Moose came along, people had struggled with Perl 5 OO and invented a number of creative and/or dodgy ways to deal with and use it. My suggestion to you is to just use Moose. A number of the Perl 5 olde guard do not recommend Moose.

As for how much effort it will be to learn OO, my answer is: not much. It's pretty simple. You look at the problem you're trying to solve and decide what the nouns are and what they should be able to do. OO features will allow you to soon create a data structure that contains not only data having to do with this noun, but also functions to operate on that data (this structure is called an "object"). The way you create objects is to first write down a model for what they should look like (a "class", which lists all the data and functions you want associated with that data). Then you call the class (as if it were a function) to create the object for you. Once you've got your object, you can set the values of its data structure, and call its functions. Those are the basics. There's a couple extra OO features you will learn about after that, for example, classes can contain (as part of their data) objects of other classes. Also, you can write one class, and then if you want a similar-but-more-specialized class, instead of writing out the first one all over again plus a few extra bits, you can just "inherit" from the first one and then throw in the new extra bits. Not rocket science -- it'll take you an evening or two to get the basics.

  • Comment on Re: kind of effort required for learning OO perl ?!