in reply to Re^2: A regex question.
in thread A regex question.

Hello FeistyLemur, and welcome to the Monastery!

See the section “Global matching” in perlretut#Using-regular-expressions-in-Perl, and in particular note the following (emphasis added.):

In scalar context, successive invocations against a string will have //g jump from match to match, keeping track of position in the string as it goes along....
A failed match or changing the target string resets the position.... The current position in the string is associated with the string, not the regexp.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^4: A regex question.
by FeistyLemur (Acolyte) on Aug 02, 2015 at 05:15 UTC

    Yes, I understand now why I was seeing the behavior in question. Things are working as I intended in my script. I just wanted to understand what I was missing about the match operator. I didn't realize the position in the string was associated with the string and not the regexp.

    I got the answer I was looking for and understand the match operator better now, thanks.