I get the following error with my class: "It is not possible to change the call to the non-lvalue subroutine in the line file.do 26." The file.do file looks something like this:
line 2: use BookController; line 3: my $bookdb = BookController->new(); ... line 26: $bookdb->dbh = 0;
And my BookController.pm looks like this:
#!/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;
Any suggestions?
source share