I'd second rjray's comment on flexibility. One key to productive Perl OO programming, IMO, is not to become bound by constraints other OO languages impose on you.

In the case of your search method, consider the fact that Perl lets you build hybrid methods that work as either instance (object) or class (static) methods. I know this is another one that drives OO purists wild, but I often find it useful. In the case of a search method, the possible application might be to either search within a row or across the entire set. Such a dual purpose method would look something like this:

sub search { my $invocant = shift; if (ref($invocant)) { $invocant->_set_search(); } else { $invocant->_instance_search(); } }

As you advance down the Perl OO path, take a look at ties and closures -- 2 Perl constructs that give you OO possibilities many other OO languages don't offer.


In reply to Re: Beginner OOP style question by steves
in thread Beginner OOP style question by Tardis

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.