go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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,
In reply to Re: Matching with /g: Is this a bug?
by Athanasius
|
|