@a = qw(a b c d e f); @b = qw(1 2 c 3 4 f); foreach $foo (@a) { if ( grep /$foo/, @b ) { print "Matched $foo in both arrays\n"; } }