# this part is just so you don't get an "requires explicit # declaration" error my @lines = getLines(); my @angel = getAngel(); my @a;my @b; # ok...here's some magic # we create a hash whose keys come from @lines. Why # do this? Since checking an element in a hash is O(1) # it is much faster than searching the array @lines # ...also, on a side node the map is so we do case # insensitive checking when we look for exists my %hash; @hash{map(lc,@lines)} = (); # ok, now we create a loop that will set $_ to the numbers # from 0 to $#angel. We could also do for (@angels) to get # the actual values, but since you pushed the index of # matches into @a and @b, I opted for this option instead. for (0..$#angel) { # ok, since we didn't actually set each hash element to any # value, we can't compare it against anything...BUT, we can # check to see whether or not it exists if (exists $hash{lc($angel[$_])}) { # hey, we have a match, take care of it } else { # darn...not a match :-/ } }