in reply to DBI's selectall_hashref and nested foreach loops

You can clean that up a bit:
my $asdf = $dbh->selectall_hashref($sth,['blah1','blah2','blah3']); while ( my ($key1, $val1) = each %$asdf ) { while ( my ($key2, $val2) = each %$val1 ) { while ( my ($key3, $val3 = each %$val2 ) { # Do something here... } } }
And even when you use for/foreach loops, it's better to declare loop variables in the loop rather than before it, e.g.:
for my $key ( keys %$hashref ) { ... }