|
Posted by Sherm Pendley on March 20, 2007, 5:55 pm
Please log in for more thread options
> I'm working on making an object oriented module in Perl for the first
> time and have run into an error that I'm having trouble with:
> "Can't call method "workbook" without a package or object
> reference..."
>
> sub CreateWorksheet
> {
> my $self = @_;
Here's the problem. This assigns the number of elements in @_ to the $self
variable. So $self is not an object, it's 2.
> #if (@_) { my $sheetname = shift; }
> my $sheetname = shift;
This pops the first element off of @_ - which is what you wanted in $self.
Another way to write these lines:
my ($self, $sheetname) = @_;
Another:
my $self = $_[0];
my $sheetname = $_[1];
And another:
my $self = shift;
my $sheetname = shift;
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net
|