Answer the question
In order to leave comments, you need to log in
Perl protected and private methods?
Please tell me how to arrange protected and private methods in OOP Perl. Thank you.
Answer the question
In order to leave comments, you need to log in
The OOP of Perl has nothing to do with the OOP of C++-like languages.
If you really want to, you can use an anonymous function as a private method and pass $self to it as the first parameter:
package MyClass;
my $private_method = sub {
my $self = shift;
# ...
};
sub public_method {
my $self = shift;
$private_method->($self);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question