in reply to looping through a hash and looking up values from another hash

defined $hash2{keys} KEYS, i suspect you want defined $hash2{$keys} instead.

I also suspect you want

print join(' ',@{ $hash1{$keys} }), "\t", $hash2{$keys}, "\n";
Instead too.