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... } } } #### for my $key ( keys %$hashref ) { ... }