I have a class that has a new method and uses that object to call method X. When I call X from the object the first value of the parameters is $self and the rest are the values I sent in. Now when I call that same method from another method on the object the first value is no longer $self and its just the values being sent in. How do I address this situation?
Sample:
my $p = TEST->new;
$p->mymethod(1,2,3); # @_ = 'self, 1, 2, 3'
but if in ‘mymethod’ is called by another method:
sub anothermethod{
my ($self, $a) = @_;
mymethod(1,2,3); # @_ = '1,2,3'
}
How do I write ‘mymethod’ so it handle both situations? Or am I fundamentally doing something incorrect?
Just as you did this:
you need to be explicit about what object you are calling the method on (even within the class):