use strict; use warnings; my @x = ("aaBxyz", "..Bxys", "bbxyzzy", "xxAx"); # for each element in the array @x, # pass that element to the array @result if # if the 3rd character is either A or B # followed by at least one character. my @result = grep {/^..(A|B)./}@x; print "$_\n" for @result; =prints aaBxyz ..Bxys xxAx =cut