Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
2.14k stars 587 forks source link

inconsistent pos() after scalar m//gc vs. list m//gc in 5.5.3 #759

Closed p5pRT closed 22 years ago

p5pRT commented 25 years ago

Migrated from rt.perl.org#1683 (status was 'resolved')

Searchable as RT1683$

p5pRT commented 25 years ago

From @RandalSchwartz

# I expect this​: pos = 2; @​words = (); push @​words\, $1 while /\G\s*(\w+)/g; print "scalar g (@​words) = "\, defined pos() ? pos() : "undef"\, "\n"; # "ed barney"\, respected initial pos\, pos is undef at end

# I expect this​: pos = 2; @​words = (); @​words = /\G\s*(\w+)/g; print "list g (@​words) = "\, defined pos() ? pos() : "undef"\, "\n"; # "ed barney"\, respected initial pos\, pos is undef at end

# I expect this​: pos = 2; @​words = (); push @​words\, $1 while /\G\s*(\w+)/gc; print "scalar g (@​words) = "\, defined pos() ? pos() : "undef"\, "\n"; # "ed barney"\, respected initial pos\, pos is 11 at end

# I think this is a bug​: pos = 2; @​words = (); @​words = /\G\s*(\w+)/gc; print "scalar g (@​words) = "\, defined pos() ? pos() : "undef"\, "\n"; # "ed barney"\, respected initial pos\, but pos is still 2??? __END__

From my read of the docs\, I think pos() should be left at the end of the last successful match if /c is present. Any takers? Anyone got a patch? Either the docs or the behavior is off here.

-- Randal L. Schwartz - Stonehenge Consulting Services\, Inc. - +1 503 777 0095 \merlyn@&#8203;stonehenge\.com \<URL​:http​://www.stonehenge.com/merlyn/> Perl/Unix/security consulting\, Technical writing\, Comedy\, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

p5pRT commented 22 years ago

From @gbarr

Fixed in 5.8.0

p5pRT commented 22 years ago

@gbarr - Status changed from 'open' to 'resolved'