for (keys %hash1) { if (exists $hash2{$_}) { say "Files $hash1{$_} and $hash2{$_} are equal"; } }