while() { chomp ($_); push(@peptide, $_); #adds each line to an array print "peptides: @peptide\n"; foreach my $test_prot_id (keys %proteins) { my $test_prot_seq = $proteins{$test_prot_id}; if ($test_prot_seq =~/($peptide)/) { print "found $peptide in $test_prot_id\n"; $results{$test_prot_id} ++; } } }