S
Steve
I have a class that takes in an object in its constructor, and stores
it as a member variable as follows:
# INSIDE CONSTRUCTOR
....
$self->{MY_OBJECT} = shift;
....
I can make calls to this member object's methods inside the
constructor, and they work fine:
....
print $self->{MY_OBJECT}->myMethod();
....
I have a getter method in this top-level object that returns the member
object:
sub getMyObject {
my $self = shift;
return $self->{MY_OBJECT};
}
However, when other code retrieves this object using the getter method,
it is unable to make method calls against that object. For example,
this code:
$topObject->getMyObject()->myMethod();
... generates an error message like this:
Can't call method "myMethod" without a package or object reference at
myScript.pl line 30.
Can anyone point me in the right direction as to what I might be
missing here? Thanks in advance!
it as a member variable as follows:
# INSIDE CONSTRUCTOR
....
$self->{MY_OBJECT} = shift;
....
I can make calls to this member object's methods inside the
constructor, and they work fine:
....
print $self->{MY_OBJECT}->myMethod();
....
I have a getter method in this top-level object that returns the member
object:
sub getMyObject {
my $self = shift;
return $self->{MY_OBJECT};
}
However, when other code retrieves this object using the getter method,
it is unable to make method calls against that object. For example,
this code:
$topObject->getMyObject()->myMethod();
... generates an error message like this:
Can't call method "myMethod" without a package or object reference at
myScript.pl line 30.
Can anyone point me in the right direction as to what I might be
missing here? Thanks in advance!