Re: referencing a param and $self in an OO subroutine



On 03/20/2007 11:18 AM, Marc wrote:
I've made some progress based on your feedback. When I tried:

my ($self, $sheetname) = @_;

it thought $self was the value of what the $sheetname was supposed to
be, throwing the following error:

Use of uninitialized value in concatenation (.) or string at line 161.
Can't locate object method "workbook" via package
"[sheetnameVariable]" (perhaps you forgot to load
"[sheetnameVariable]"?) at line 162.

the print sheetname statement had output:
"sheetname = "

So I flipped them and the print sheetname statement had output:
"sheetname = [sheetnameVariable]"

but I got this error at the same line (161):
"Can't call method "workbook" on an undefined value"

so apparently it still doesn't know what $self is. This method is
being called from another method in the module with like this:

my $Work*** = CreateWork***($title);


That's not how you call methods. Try this:

my $Work*** = $self->CreateWork***($title);

Read "perldoc perlboot" again.

sub CreateWork***
{
my ($sheetname, $self) = @_;

If this is a method, $self will go first.

[...]
.