in reply to hash key lookups failing

There are a large and radical number of incongruences between the things you are saying and what the posted code belies. You should read "Advanced Perl Programming" or type perldoc perlref or buy another good Perl book on references.

Anyway this code you posted :

my @keys=$count_stmnt->fetchall_arrayref(); $vals=@keys[0];
Does not fetch into a hashref. Why would you think a function called fetchall_arrayref returns a hashreference? I think you should also type perldoc DBI and read that as well.

Here is how to get a hashref and use it

my $hashref = $sth->fetchrow_hashref; $hashref->{key};
But like I said, you appear to have a large number of basic and crucial misunderstandings. Also buy the book "Programming the Perl DBI" from O'Reilly.

I hope this post sounds direct but not rude.