I usually use the underscore convention to indicate protected methods. For private methods, subrefs held in lexical vars are my prefered way:
my $private_method = sub { my ($self) = @_; . . . }; $self->$private_method();
If you know how to lexical scope like a fox, you can even keep it private from different parts of your class:
{ my $very_private_method = sub { my ($self) = @_; . . . }; $self->$very_private_method(); # Can call it here } # But this is a compile error under "use strict 'vars'" $self->$very_private_method();
That's a level of privacy most languages don't have.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
In reply to Re: Private and Protected class methods
by hardburn
in thread Private and Protected class methods
by radiantmatrix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |