while ($str =~ /(N+)/g) { print length($1), "\n"; }
See perlretut and maybe perlre for an explanation.
(Updated after reading the question more carefully this time)
In reply to Re: count consecutive characters
by moritz
in thread count consecutive characters
by Boetsie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |