in reply to Returning and passing references to hashes

See perldoc perlreftut about using references.

If you have hashrefs in scalar variables (as you do, e.g., $dbids), you can loop through the values like so:

for my $val (values %$dbids) { # Do something with a value...

Caution: Contents may have been coded under pressure.