develooper Front page | perl.perl5.porters | Postings from December 2010

[perl #81286] Subsequent assertions with \G and gc modifiers dont work as expected

Thread Next
From:
Father Chrysostomos via RT
Date:
December 26, 2010 14:28
Subject:
[perl #81286] Subsequent assertions with \G and gc modifiers dont work as expected
Message ID:
rt-3.6.HEAD-5425-1293402528-913.81286-15-0@perl.org
On Sat Dec 25 14:26:58 2010, gelbman@gmail.com wrote:
> Under Perl 5.12.1, the following test does not succeed.
> 
> use Test::More;
> $_ = "abc";
> ok /\G^/gc;
> ok /\G^/gc; # not ok
> 
> Since you can't be on the "other side" of an assertion, I would expect  
> subsequent regexes to work as the one before them.
> 
> Also, if between the regexes, I put the following, things work as  
> expected:
> 
> pos($_) = pos($_);

Scalar //g will not match a zero-length substring of the same string in
the same position twice in a row. This is so that split //, "foo" will
work without looping. Setting pos == pos is a common way to reset the
internal flag that tracks whether a zero-length match has occurred. I’m
not at all surprised that is behaves as you described.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About