Background

In Perl 6, the string substitution operation s/// has a method
backend. Instead of s:g/foo/bar/ (globally substitute foo by bar)
you can write:

say'some foo with sugar'.subst(/foo/,'bar',:g);

Currently Rakudo doesn't parse the adverbs at the front, but supports the
named arguments in the method form.

What you can do

Implement the :samecase named parameter. With this option, the
case (upper/lower) of the original string is applied to the substitution:

say'The foo and the bar'.subst(/:i the/,'that',:g,:samecase);# should produces 'That foo and that bar'

The actual case transformation is implemented in form of the
samecase($substitution, $pattern) function already. If the
replacement part is actually a code object, the samecase
translation should apply to its return value.

When you've modified the test and/or the source file, you can run it
with

make t/spec/S05-substitution/subst.t

Submission

Please submit your patches to the perl6-compiler mailing list, and CC' me
(moritz.lenz@gmail.com). As always, feel free to ask any questions about this
question either on that mailing list, or on our IRC channel.

Update: A working patch from Hongwen Qiu has been applied,
as well as some tests; more tests are still welcome.