> So with your blessing, I'll include the following as the new
replace()
> virtual method.
I have created a simple test, which compares results of native
perl s/// (via eval) and proposed template 'replace' vmethod. It
seems that we still have a lot of problems with "last" version of
replace. The replacement is performed on source string, so it may
easily break it:
$s = 'foo $1 bar';
$s =~ s/(foo)(.*)(bar)/$3$2$1/;
# we'll get 'bar $1 foo'
[% s.replace('(foo)(.*)(bar)','$3$2$1') %]
# we'll get 'bar foo foo'
There are other issues with backslashes - perl handles \1-\9 as
$1-$9, but \10 and so on are handled as octal character code (as
in double-quoed strings).
I've placed my test file (vmeth_replace.t) here:
http://martynoff.info/tt2/ - please take a look at it. Maybe it
would be useful to include this test into distribution.
--
Sergey Martynoff
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates