use strict; use warnings; my %hash = ("One","1","Two","2","Three","3","Four","4"); my @lines = ("One", "Two", "Three"); foreach my $i (keys %hash) { foreach my $n (@lines) { if ($i eq $n) { print "$i,", $hash{"$i"}, ",Hit\n"; } else { print "$i,", $hash{"$i"}, ",Miss\n"; } } }