in reply to while =~ consecutive matching problem

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

foreach(@lines) { while(m{$pattern}g) { $count++; } }
edit Eimi Metamorphoumai is absolutely right. You need to use non-greedy matching.


Grygonos