On Fri, Jun 17, 2005 at 03:33:50PM -0400, Larry Underhill wrote:

> But what I would really like to do is wrap $1 around a big set o'
> Docbook tags. I figured I would just call  a function to do that, but it
> doesn't work. 
> 
> $text =~ s!javascript_with_(.*)_string! trans($1) !g;
> 
> sub trans {
>     my $foo = shift @_;
>     return "<several-nested-tags>$foo</several-nested-tags>\n";
> }
> 
> I'm poking with 'man perlre', but not making much headway. Can I call a
> function in the substitution part of a regexp match?

You can *e*xecute any arbitrary code in the replacement, by adding the /e
modifier to the substitution.  s/// is documented with the other quote-like
operators in perlop.

Ronald
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to