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.


In reply to Re: kind of effort required for learning OO perl ?! by Anonymous Monk
in thread kind of effort required for learning OO perl ?! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.