in reply to [bugs?] perldoc perlre, \G and pos()
BUT what's really confusing me is that pos($str) is empty afterwards!
pos is updated by every search. It is either advanced on success, or reset on a match failure (unless you use /c). If it didn't reset, a match somewhere in the program could affect an unrelated match elsewhere in the program.
produces [...] and an endless loop!
Position zero is the start of the string. It doesn't surprise me that it thinks it hasn't matched yet.
It lets you do something silly like /.\G/ assuming you know what you are doing. Expect problems if you break that trust by trying to match the character before the start of the string and nothing else.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [bugs?] perldoc perlre, \G and pos()
by LanX (Saint) on Sep 29, 2009 at 14:50 UTC | |
by ikegami (Patriarch) on Sep 29, 2009 at 15:22 UTC | |
by LanX (Saint) on Sep 29, 2009 at 15:29 UTC | |
by ikegami (Patriarch) on Sep 29, 2009 at 15:31 UTC | |
by LanX (Saint) on Sep 29, 2009 at 15:35 UTC | |
| |
by JavaFan (Canon) on Sep 29, 2009 at 21:11 UTC | |
by LanX (Saint) on Sep 30, 2009 at 12:49 UTC | |
by JavaFan (Canon) on Sep 30, 2009 at 14:19 UTC | |
by ikegami (Patriarch) on Sep 29, 2009 at 15:23 UTC |