in reply to perl6: subst with capture brackets
If you want to use the match object in the substitution part, there's an ugly workaround, which is to use the method form of subst, and using the first positional parameter:
my $v = "test"; $v.=subst(/(\w)/, -> $/ { say $0; 'X' }); say $v # output: t Xest
I know that $/ should be available in the substitution part, but I'm not sure what the spec says about the outside - especially in the case of s:g/// this wouldn't make all too much sense.
Update: both forms, as well as using $0 in the right-hand side of the s/// work now in rakudo.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl6: subst with capture brackets
by Fox (Pilgrim) on Aug 16, 2010 at 12:52 UTC |