Aaron Sherman writes:
> On Wed, 2004-05-12 at 14:22, Juerd wrote:
>
> > Actually, can't we just use the . for s///?
>
> Well, that brings up something that I don't think Larry has covered yet.
> That is, it brings into question what s/// *is* in the grammar.
Well, I imagine it's just a macro called C<s> that turns itself into an
appropritate sub call.
As a method, I don't think it exists. It's more of a $str.subst(). You
can't add special parse rules to methods, since you can't do polymorphic
parsing[1]. So you'd more likely have:
my $subd = $str.subst(
rx/ \w+ / => "WORD",
);
Which would open up:
my $subd = $str.subst(
rx/ I\< (.*?) \> / => { "<i>$1</i>" },
rx/ \< / => '<',
rx/ \> / => '>',
);
à la Regexp::Subst::Parallel. Provided the hypothetical scoping works
out there. Hmm, would the scope of $1 propagate?
Luke
[1] I feel a new experimental language coming on... >:-}