【发布时间】:2012-03-04 02:31:46
【问题描述】:
我的班级出现以下错误:“无法在 file.do 第 26 行修改非左值子例程调用。”我的 file.do 看起来像这样:
line 2: use BookController;
line 3: my $bookdb = BookController->new();
...
line 26: $bookdb->dbh = 0;
我的 BookController.pm 看起来像这样:
#!/usr/bin/perl
package BookController;
use strict;
sub new
{
my $this = shift;
my $class = ref($this) || $this;
my $self = {};
$self->{DBH} = undef;
bless $self, $class;
return ($self);
}
sub dbh
{
my $self = shift;
$self->{DBH} = shift if (@_);
return $self->{DBH};
}
1;
有什么建议吗?
【问题讨论】: