in reply to Matching with /g: Is this a bug?
As choroba says, this is the documented behaviour. See also “Global Matching” in perlretut#Using-regular-expressions-in-Perl.
Perhaps it’s the context that’s confusing you? In scalar context, pos is reset only when the match fails or the string is changed. But print supplies list context to its arguments, so all remaining matches are returned and pos is always reset.
Update: Added the word “remaining” as a correction in response to choroba’s post, below.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching with /g: Is this a bug?
by choroba (Cardinal) on May 27, 2013 at 15:21 UTC |