in reply to Re^2: while =~ consecutive matching problem
in thread while =~ consecutive matching problem

Ok, take your second test case, the one that doesn't work as you expect, and let's walk through it.

  1. Match "_x_y_" (I used _ to indicate a space character). One is found, and the pattern match position pointer is advanced to the 2nd 'x'.
  2. Look for another "_x_y_", but there isn't one, because you're already at position 'x', not position '_' (space).

What you may want is something like this:

m/\s$pattern(?=\s)/

This won't gobble the second space char.


Dave