in reply to Confused by RegEx count

Melly, I found a couple of articles discussing your interesting challenge from two well-respected Perl book authors:

From brian_d_foy's article:

Perl has a few ways to do it (many languages do too, but no one cares) because there are actually several different problems you could be solving. A good answer takes into account the level of problem that you are trying to solve.

So if you provided more background and context on the specific problem you're trying to solve, we could provide better advice.

While the benchmarks of this little problem are interesting and instructive, code clarity and maintainability are usually more important than performance, as analysed in much more detail at on Code Optimization.

👁️🍾👍🦟