M
michael.shnitzer
Why would the following code work in a regular hash environment but
dereference when using a DBM hash?
"Can't locate object method "docno" via package
"Document=HASH(0x4001d0cc)" (perhaps you forgot to load
"Document=HASH(0x4001d0cc)"?) at read.pl line 6."
#! /usr/bin/perl -w
use strict;
dbmopen(my %hash, "db", 0777);
$hash{mike} = new Document;
print $hash{mike}->docno;
package Document;
sub new
{
my $self = {
document_number => "DOC123",
};
bless $self;
}
sub docno
{
my $self = shift;
return $self->{document_number};
}
dereference when using a DBM hash?
"Can't locate object method "docno" via package
"Document=HASH(0x4001d0cc)" (perhaps you forgot to load
"Document=HASH(0x4001d0cc)"?) at read.pl line 6."
#! /usr/bin/perl -w
use strict;
dbmopen(my %hash, "db", 0777);
$hash{mike} = new Document;
print $hash{mike}->docno;
package Document;
sub new
{
my $self = {
document_number => "DOC123",
};
bless $self;
}
sub docno
{
my $self = shift;
return $self->{document_number};
}