> Is someone bringing the m// operator to TT2 ?  How about 
> .replace() with
> access to the $numbers ?  Would be useful.

Unfortunately, the right side of replace is deliberately quoted for security. You 
shouldn't be able to call arbitrary perl code from the templates. And parsing out just 
the $1 style variables isn't the obvious case it first appears.

[% a.replace('.*','@{[`rm -rf`]}') %]

Of course, if you aren't afraid of that (and you promise to never send the replace 
side directly from date that a site user could load and you dont mind potentially 
fatal errors) then you can do this after calling 'use Template;':

Template::Stash::STASH_OPS->{replacex}  => sub {
  my ($str, $search, $replace) = @_;
  $replace = '' unless defined $replace;
  return $str unless defined $str and defined $search;
  eval "\$str =~ s^A$search^A$replace^Ag";
  return $str;
};

But seriously, you'll probably be sorry eventually...

--mark


Reply via email to