in reply to replacing "dynamic" variables
s/(\${\w+})/find_value_for_var("$1")/e
The above code will find alphaneumerical sequences enclosed in ${}, and then send them to the find_value_for_var() function. Perhaps a more coherent example is
s/(\d+)/$1 + 5/e;
Which will find a sequence of digits, then construct the perl expression for those digits, then an addition operator, and then a five, and then evaluate this code, returning the number that was matched plus five.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: replacing "dynamic" variables
by Jenda (Abbot) on Apr 10, 2004 at 16:50 UTC |