C
Colvin
I'm trying to store a hash of a hash in a DBM database, but I keep
running into problems with my references. The enclosed script runs
without errors; the errors don't appear until I uncomment the commented
lines (the DBM functionality). How do I fix my references to make them
compatible with a DBM database?
Thank you,
Alec Colvin
----- error message ----------
13457 Can't use string ("HASH(0xba0c34)") as a HASH ref while "strict
refs" in use at c:\perl_test\database1.pl line 20.
----- code -------------------
use strict;
my %data;
# dbmopen(%data, "c:\\perl_test\\database", 0666) or
# die "Can't open the database";
my $person1 = { "fname" => "Stevie",
"lname" => "Wonder"
};
%data = ( "13457" => $person1,
);
my @ID_number = keys(%data);
@ID_number = sort(@ID_number);
my $i;
for ($i = 0; $i < @ID_number; $i++) {
print STDOUT "$ID_number[$i] ";
print STDOUT qq|$data{$ID_number[$i]}->{"fname"} |;
print STDOUT qq|$data{$ID_number[$i]}->{"lname"}\n|;
}
# dbmclose(%data);
running into problems with my references. The enclosed script runs
without errors; the errors don't appear until I uncomment the commented
lines (the DBM functionality). How do I fix my references to make them
compatible with a DBM database?
Thank you,
Alec Colvin
----- error message ----------
13457 Can't use string ("HASH(0xba0c34)") as a HASH ref while "strict
refs" in use at c:\perl_test\database1.pl line 20.
----- code -------------------
use strict;
my %data;
# dbmopen(%data, "c:\\perl_test\\database", 0666) or
# die "Can't open the database";
my $person1 = { "fname" => "Stevie",
"lname" => "Wonder"
};
%data = ( "13457" => $person1,
);
my @ID_number = keys(%data);
@ID_number = sort(@ID_number);
my $i;
for ($i = 0; $i < @ID_number; $i++) {
print STDOUT "$ID_number[$i] ";
print STDOUT qq|$data{$ID_number[$i]}->{"fname"} |;
print STDOUT qq|$data{$ID_number[$i]}->{"lname"}\n|;
}
# dbmclose(%data);