foreach $G (@array1) { push @Coordinates, grep { /$G/ } @array2 }