M
michael.shnitzer
It was my understanding that once a DBM hash was tied to a file, it
can be accessed using the same methods as a regular hash. For
simplicities sake I created a small perl program to demonstrate what I
am trying to do:
***********************************
#! /usr/bin/perl -w
use warnings;
my %hash = ( );
dbmopen(%hash, ".data/documents", 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};
}
**************************************
If I run this program with the DBM hash it returns "Can't locate
object method "docno" via package "Document=HASH(0x4001d0cc)" (perhaps
you forgot to load "Document=HASH(0x4001d0cc)"?) at read.pl line 11."
But if I run this program without opening the DBM hash, then the
program returns the expected result of DOC123.
Obviously there is a difference in accessing the hash data when it is
being read from a DBM hash that I am missing.
Any suggestions would be appreciated.
Thanks,
--Mike
can be accessed using the same methods as a regular hash. For
simplicities sake I created a small perl program to demonstrate what I
am trying to do:
***********************************
#! /usr/bin/perl -w
use warnings;
my %hash = ( );
dbmopen(%hash, ".data/documents", 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};
}
**************************************
If I run this program with the DBM hash it returns "Can't locate
object method "docno" via package "Document=HASH(0x4001d0cc)" (perhaps
you forgot to load "Document=HASH(0x4001d0cc)"?) at read.pl line 11."
But if I run this program without opening the DBM hash, then the
program returns the expected result of DOC123.
Obviously there is a difference in accessing the hash data when it is
being read from a DBM hash that I am missing.
Any suggestions would be appreciated.
Thanks,
--Mike