http://www.perlmonks.org?node_id=432501


in reply to Re: counting overlapping patterns
in thread counting overlapping patterns

$count++ while $string =~ /\GAA/gc;
Er, no, the \G there serves no purpose as that's the default behaviour anyway. On this other hand this will work, by only consuming the first character of the match:
$count++ while $string =~ /A(?=A)/g;

Dave.