
budman
User
Apr 7, 2012, 7:56 AM
Views: 2344
|
|
Re: [ChopperCharles] private and protected methods
|
|
|
So you do not want this to be inherited or used by anything else.
# create a class attribute my @myFriends = ( __PACKAGE__, "TacoBell" ); # change the unless statement in __foo to: ( my $object = (caller)[0] ) =~ s/.*:://; unless ( grep { $object } @myFriends ) { $m_LastError = "Access to private method denied. $object"; return -1; } Strange though, @ISA is pretty safe with inheritance. Experienced Perl programmers have a lot of respect for each others logic and implementations. They know the limitations of the language and respect it and make it work. Just because objects can be accessed, or jail-breaked, or whatever, a majority if not all try to follow the best practice guidelines.
(This post was edited by budman on Apr 7, 2012, 8:05 AM)
|