http://www.perlmonks.org?node_id=67486


in reply to How do I compare two strings against two arrays respectively?

Here's another way to do it, if I correctly understand what you want to do. You want to find an index $i for which $a[$i] eq $a and $b[$i] ne $b (that is, your condition holds at the same index). So why are you searching the array elements? It's better to search for an appropriate index!
@indices = grep { $a[$_] eq $a and $b[$_] ne $b } (0..$#a);