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


in reply to counting overlapping patterns

Why not let Perl do the incrementing itself?

$count = () = "AAAA" =~ m/(?=AA)/g;