for (keys %hash1) { next if exists $hash2{$_}; # ... your main loop code here }