> I was also able to re-write it using a loop (tail-recursion
style)
> rather than recursively calling itself. Although I preferred
the
> elegance of your recursive approach, this way makes it a little
easier
> to patch directly into $Template::Stash::SCALAR_OPS without
having to
> create a separate named subroutine that we can recursively call.
>
> So with your blessing, I'll include the following as the new
replace()
> virtual method.
But what about support for backslash-escaped '$' sign in replace
string? It seems to be achieved quite easily, changind the line
where actual replace takes place:
> $matched =~ s/\$$i/$backref/g;
with this:
$matched =~ s/(?<!\\)\$$i(?!\d)/$backref/g;
This also solves probles with "unused" backreferences, when you
use something like replace("(this)","that$10") ending up with
"that0" instead of desired "that".
--
Sergey Martynoff
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates