Thanks for asking this question as I'm (almost) in the same boat. I have some training in Java but rely on Perl for most of what I do. I want to do a re-write of a Perl project from procedural to OO that's becoming increasingly unwieldy and difficult to maintain and expand. Before I start though I've been trying to understand the best way to go about learning OO in Perl and one that I think makes sense.

To me, native Perl OO (blessing an anonymous hash ref) doesn't make sense. You get no encapsulation (and hence potential namespace conflicts) and get none of the benefits of strict and warn since you're storing data according to keys, not hard-coded variables. This is crazy, completely insane! I desperate want strict and warn when I'm trying to make more wieldy code out of my large data structures, and especially when I'm trying to learn how to do it.

So I started investigating inside-out objects, a clever hack on top of Perl's native OO that encapsulates instance data with compile-time checking, just the way I want it. However I got a number of suggestions before settling on Class::InsideOut as the best potential solution (but not without significant reservation). Then I got suggested Moose as a nice OO framework. Moose on the surface looks good but to me it's a huge black box and not part of the standard distro, so my code becomes that much less portable (which is a goal).

So you guess I could say I'm confounded by the TMTOWTDI nature of it all - with objects, seriously, I only need one paradigm that looks and feels like Perl. At this point I'm ready to throw up my hands and just use the native Perl method to see if it's worth all the fuss to avoid it, although I know if anything should go awry I may regret my decision. I look forward to weighing all the suggestions in this thread.


In reply to Re: looking towards learning OOP by whakka
in thread looking towards learning OOP by spx2

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.