if (grep {$_ eq $string} @uniq_strings) { $match++ ; } #using hash elsif (exists $dict{$string}) { # loop over all elements in array of hash LOOP: foreach $element (@{$dict{$string}}) { if (grep {$_ eq $element} @uniq_strings) { $match++ ; last LOOP; } } }