Document use of pos() and /\G/
Subject: Re: resetting pos broken in _20
On Mon, 13 Jan 1997 12:49:24 EST, Ilya Zakharevich wrote:
>Gurusamy Sarathy writes:
>> What's wrong with saying
>> C<pos $foo = length $foo> after /g fails, to get the behavior
>> you want?
>
>Since this has different semantics. You need to get `pos' before each
>match, and reset it after each failing match.
>
> /=/g; /;/g; /=/g; /;/g;
>
>may give you non-monotoneous movement of `pos' over the string, which
>is a bad thing.
Ahh, of course.
>But I still do not understand what you mean by "having pos at
>end". The bug was that position is reset at failing match, probably
>you have some other case in mind?
Never mind, I was missing the possibility of chaining //g matches
with the \G escape :-(
>I did not realize that pos was available at perl 4.?, bug-for-bug
>compatibility may be a reason if this was so for so many years...
The bug fix seems to make a lot sense (to me) now. \G was essentially
useless without the new "incompatiblity", eh?
Here's a pod update that documents current behavior in all the
places I could think of.
- Sarathy.
gsar@engin.umich.edu
p5p-msgid: <
199701132013.PAA26606@aatma.engin.umich.edu>