http://www.perlmonks.org?node_id=200099


in reply to REALLY Private Methods in perl: Is Perl Flexible enough to be made Inflexible?

Yes. There are quite a few variations of "privateness" documented in theDamian's excellent Object Oriented Perl. You can check the file and line number of caller, for example.

However, the moment you do that, I would not want to maintain your code. Every attempt I've seen at privacy has made the code more unmaintainable.

Just name your "private" methods with a leading underscore, and put "do not call outside of this class" in a comment. People will get the idea, and they deserve what they get when they violate it. Why is that so hard to understand?

-- Randal L. Schwartz, Perl hacker