Skip Menu |
Report information
Id: 130688
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] .subst/.subst-mutate with :g do not set $/ to all the matches
Download (untitled) / with headers
text/plain 985b
When the :g adverb is used with .match, s/// or, S///, the $/ contains a list of match objects for each of the matches made during matching/substitution: <ZoffixW> m: 'fog'.match: :g, /./; say $/ <camelia> rakudo-moar 97359a: OUTPUT«(「f」 「o」 「g」)␤» <ZoffixW> m: S:g/./x/ given $ = 'fog'; say $/ <camelia> rakudo-moar 97359a: OUTPUT«(「f」 「o」 「g」)␤» <ZoffixW> m: s:g/./x/ given $ = 'fog'; say $/ <camelia> rakudo-moar 97359a: OUTPUT«(「f」 「o」 「g」)␤» However, the .subst/.subst-mutate methods only return the last match made and not all of them: <ZoffixW> m: 'fog'.subst: :g, /./, 'x'; say $/ <camelia> rakudo-moar 97359a: OUTPUT«「g」␤» <ZoffixW> m: ($ = 'fog').subst: :g, /./, 'x'; say $/ <camelia> rakudo-moar 97359a: OUTPUT«「g」␤» I briefly looked at the code and they seem to call match + APPLY-MATCHES just like S/// ops do. No idea why the $/ ends up with just the final match.
Download (untitled) / with headers
text/plain 265b
Also affects :x and :nth modifiers <Zoffix> m: 'mmmmmmm'.subst: :x(1..3), /m/, 'g'; say WHAT $/ <camelia> rakudo-moar 6a77cd: OUTPUT: «(Match)␤» <Zoffix> m: 'mmmmmmm'.subst: :nth(1..3), /m/, 'g'; say WHAT $/ <camelia> rakudo-moar 6a77cd: OUTPUT: «(Match)␤»


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org