You are searching for spaces around your pattern so yes it should be expected to only match once in the second case. Knowing your exact pattern would be the biggest help in solving this quandry. Also I would reccomend this construct
edit Eimi Metamorphoumai is absolutely right. You need to use non-greedy matching.foreach(@lines) { while(m{$pattern}g) { $count++; } }
In reply to Re: while =~ consecutive matching problem
by Grygonos
in thread while =~ consecutive matching problem
by p.s
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |