I'd think you'd want to know that whoever is calling the _protected_method() ->can( "_protected_method" )

That's correct, and actually -- it works. The level for caller took some playing with, but caller(1) turns out to be right: caller(0) would be the _protected_sub itself, while caller(1) is whomever called the _protected_sub.

I'd name this method _PROTECTED()

Good point, noted.

In particular, consider a case where I've "exported" a sub into my method namespace.

Hm, interesting. I hadn't considered what would happen when exporting methods like that, since I've never had need to do things like that. I will have to bring it up with my design team and see what to do about it. That particular case seems to work (though I don't entirely understand why), but I can see where more complicated cases in the same class might cause problems.

Thank you, and ++;

<radiant.matrix>
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

In reply to Re^5: Private and Protected class methods (caller) by radiantmatrix
in thread Private and Protected class methods by radiantmatrix

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.