in reply to Matching with /g: Is this a bug?
In scalar context, each execution of m//g finds the next match, returning true if it matches, and false if there is no further match. The position after the last match can be read or set using the pos() function; see pos. A failed match normally resets the search position to the beginning of the string, but you can avoid that by adding the /c modifier (for example, m//gc). Modifying the target string also resets the search position.
The position where to continue matching is linked to the variable that is used, not to the regex!.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching with /g: Is this a bug?
by morgon (Priest) on May 27, 2013 at 15:18 UTC | |
by choroba (Cardinal) on May 27, 2013 at 15:23 UTC |