in reply to Re^3: [bugs?] perldoc perlre, \G and pos()
in thread [bugs?] perldoc perlre, \G and pos()

And I said if it "*thinks* it hasn't matched yet" the while condition is false not true!

Cheers Rolf

  • Comment on Re^4: [bugs?] perldoc perlre, \G and pos()

Replies are listed 'Best First'.
Re^5: [bugs?] perldoc perlre, \G and pos()
by ikegami (Patriarch) on Sep 29, 2009 at 15:31 UTC

    1st Pass: It thinks it hasn't matched yet because pos == 0, so it matches, setting pos = 0.
    2nd Pass: It thinks it hasn't matched yet because pos == 0, so it matches, setting pos = 0.
    3rd Pass: It thinks it hasn't matched yet because pos == 0, so it matches, setting pos = 0.
    ...

      while() puts scalar context, so just _one_ try to match, and no match results in false!

      ...no repeated matches like in list context.

      Cheers Rolf

        You clearly see that it does match, so why do you keep saying it doesn't match in response to my explanation?

        1st Pass: It thinks it hasn't matched yet because pos == 0, so it matches, setting pos = 0.
        2nd Pass: It thinks it hasn't matched yet because pos == 0, so it matches, setting pos = 0.
        3rd Pass: It thinks it hasn't matched yet because pos == 0, so it matches, setting pos = 0.
        ...

        ...no repeated matches like in list context.

        The while isn't there for decoration. It's the one doing the repeating.