You may have noticed that in all the responses so far nobody used function protoypes. They dont do what you probably think they do and you should avoid them like the plague. They are one of Perls many "dont use this until you know why this should be used, if ever" features. Specifically in your case

sub search($) { ... }

is both misleading and IMO wrong. Methods _always_ take at least one parameter ($self) and prototypes are ignored when a subroutine is invoked via a method call. So they wouldnt directly break any OO code involved, but it is common knowledge that

$obj->method($parameter);

is more or less equivelent to

PACKAGE::method($obj,$parameter)

But the prototype you have used would prevent the second call from being made. This will only annoy the power user who deliberately did this for some presumably good reason, and really does no good so you should just drop the prototype.

sub search{ ... }

Or am I maybe thinking about this all wrong?

Quite possibly yes. Concern over private data managment is much more important in languages where you are linking to precompiled libraries that you do not have the code for. In perl its usually quite sufficient to mark data as private by some form of notational convention, and then leave it at that. The issue in Perl for private data is mostly to make accidental corruption unlikely not to make the data 100% absolutely unaccessable by external entitities. (Which is in fact more or less impossible, given the various devious modules out there.)


---
demerphq

<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

In reply to Re: Package-Level Variables by demerphq
in thread Package-Level Variables 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.