There's also the simple:
while ("AAAA" =~ /A(A+)/g) { $count += length($1); }
Unlike C's strlen, Perl's length doesn't loop, so this snippet is compliant with your request for no further looping.
In reply to Re: counting overlapping patterns
by ikegami
in thread counting overlapping patterns
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |