for my $i (0 .. $#dna){ if(! exists $pairs{$dna[$i].$comp[$i]}){ print "mismatch: ...."; } }