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

Re: [MacPerl] interpolating



aksuska@insideflyer.com (A K Suska) wrote:

>> Straightforward but inelegant:
>> 
>> s/<!--(\$[a-zA-Z_]\w*)-->/$$1/g;
>> 
>> This treats the value of $1 as a symbolic reference to another variable.
>
>better to do:
>    s/<!--\$([a-zA-Z_]\w*)-->/${$1}/g;
>
>Unless you use strict, where you would have to use Ken William's suggestion:
>   s/<!--(.*?)-->/$1/eeg;

Or even stricter, 
    s/<!--(\$[a-zA-Z_]\w*)-->/$1/eeg;

The difference is in how much you trust your page creators.  If you need to
protect against damage they might do, use the latter.  If you want more
flexibility, use the former.

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



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