The problem is that your regex potentially matches zero characters, so a loop like
while (/\s*/g) { ... }
Would loop infinitely. To prevent that, perl has some extra magic asociated with zero-width matches and /g, which you observe here. The obvious solution is to not use a regex which can match zero characters. You can prevent resetting of pos by using the /gc modifiers.
In reply to Re: [Perl 5.14, regex]: Problems with /g, \G and pos()
by moritz
in thread [Perl 5.14, regex]: Problems with /g, \G and pos()
by Darkwing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |