my $strTest = "ABCDpF"; if (grep {m/.?.?.?.?p.?/i} $strTest) { print "String matched the Pattern"; }