in reply to perl module subroutine
Every subroutine can be used from the object and externally. There are no private methods/subroutines in Perl.
There is one thing to remember - you cannot (or rather, should not try to) make a subroutine that can act as both, a method and a plain subroutine. No good comes of that.
package My::Class; sub my_method { my ($self,@args) = @_; print "@args\n"; }; sub other_method { my ($self,@args) = @_; $self->my_method('hello'); }; package main; My::Class->my_method('world');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl module subroutine (private method)
by LanX (Saint) on Aug 26, 2010 at 10:16 UTC | |
|
Re^2: perl module subroutine
by sudeeps (Initiate) on Aug 26, 2010 at 08:52 UTC |