http://www.perlmonks.org?node_id=866827
shawshankred has asked for the wisdom of the Perl Monks concerning the following question:

Perl experts.
I have a hash called tab2hash that has
tablenames as key and hashnames as value. I want to
initialize the hashes with the values from DB tables. And I
have the code below, however when i print the hashes
they are empty. This line is where the hash is being populated

$$VALUE_1{$k1} = $v1;

Please help with your suggestions.
my %tab2hash = qw(divisions divH regions regH); sub initHashesArraysFromDB { my ($k1, $v1); while ((my $KEY_1, my $VALUE_1) = each %tab2hash) { my $sth = $dbh->prepare("select * from $KEY_1"); $sth->execute || die "Cannot execute query: " .DBI->errstr; while (my @row = $sth->fetchrow()) { my $f1 = 0; foreach my $col (@row) { if($f1 == 0) { $f1 = 1; $k1 = $col; $v1 = $col; } else { $v1 .= "|" . $col; } } $$VALUE_1{$k1} = $v1; } } }