print "XXXXXX has appeared ", scalar grep(m/XXXXXX/, @PatternArray), " times.\n"; ... my $count = scalar grep m/XXXXXX/, @PatternArray;