D
Donavon
I am trying to load a database into a HASH of HASH. For some reason
every instance of the HASH only contains the data from the last record
pulled?
So I have a 1000 copies of the same information with different HASH
keys.
Any suggestions??
....
....
....
# loads a record into a hash
while ($data = $sth->fetchrow_hashref) {
%record = %$data;
$key = $record{'ProjectNumber'};
$hash{$key} = \%record;
};
$sth -> finish;
$dbh -> disconnect
or warn "Disconnection failed: $DBI::errstr\n";
# prints out content of HASH
foreach $key1 (keys %hash) {
print 'Level 1: ' . $key1 . "<BR>";
foreach $key2 (keys %{$hash{$key1}}) {
print $key2 . '=>' . $hash{$key1}{$key2} . "<BR>";
};
};
every instance of the HASH only contains the data from the last record
pulled?
So I have a 1000 copies of the same information with different HASH
keys.
Any suggestions??
....
....
....
# loads a record into a hash
while ($data = $sth->fetchrow_hashref) {
%record = %$data;
$key = $record{'ProjectNumber'};
$hash{$key} = \%record;
};
$sth -> finish;
$dbh -> disconnect
or warn "Disconnection failed: $DBI::errstr\n";
# prints out content of HASH
foreach $key1 (keys %hash) {
print 'Level 1: ' . $key1 . "<BR>";
foreach $key2 (keys %{$hash{$key1}}) {
print $key2 . '=>' . $hash{$key1}{$key2} . "<BR>";
};
};