in reply to Invoke the Perl string interpolation engine on a string contained in a scalar variable.
If you trust your input data (and I mean, really trust it), there is eval.
Otherwise, whitelisting the variables is the sanest approach, and then basically doing s/\$(\w+)/$1/gee.
Personally, I wouldn't allow a template to access arbitrary variables in the script and always decouple the template variable names from the inner workings of the program by using a hash, just like String::Interpolate does.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Invoke the Perl string interpolation engine on a string contained in a scalar variable.
by ibm1620 (Hermit) on Jan 15, 2019 at 20:13 UTC | |
by davido (Cardinal) on Jan 15, 2019 at 20:32 UTC | |
by ibm1620 (Hermit) on Jan 16, 2019 at 01:33 UTC | |
by AnomalousMonk (Archbishop) on Jan 16, 2019 at 01:37 UTC | |
by Corion (Patriarch) on Jan 15, 2019 at 20:24 UTC | |
by frazap (Monk) on Jan 17, 2019 at 14:57 UTC |