[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] interpolating



On Mon, Nov 29, 1999 at 08:08:03PM -0800, Nicholas G. Thornton wrote:

> <html><body>hello <!--$name--></body></html>

>           s/<!--(.*?)-->/\1/;

> or something along those lines will capture all instances of the
> variables that need replacing. But how would I interpolate $_ before
> sending it back? I mean something aside from a long list of
> s/\$name/$name/; etc


Straightforward but inelegant:

s/<!--(\$[a-zA-Z_]\w*)-->/$$1/g;

This treats the value of $1 as a symbolic reference to another variable.


There is an HTML::Template that you might want to look into as an
alternative.


Ronald

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org