|Just another Perl shrine|
Matching with /g: Is this a bug?by morgon (Deacon)
|on May 27, 2013 at 14:26 UTC||Need Help??|
morgon has asked for the
wisdom of the Perl Monks concerning the following question:
can someone explain to me the following behaviour or confirm that it is a bug:
The above code prints "hubba1hubba2" as expected.
But when I do this
it only prints "hubba2", because (I assume) the second match only starts where the first match matched (ie pos is not reset).
When I do this:
I get the correct behaviour again - I assume that the unsuccessul match attempt resets pos here.
I am using 5.14.2 and my understanding is that the behaviour in the second case is a bug or is there something I don't understand?
Many thanks! Update:
Corrected the code-examples