in reply to Re^2: Prepocessing perl code / substing variables
in thread Prepocessing perl code / substing variables
It is not about parsing perl. It is about replacing %%VARIABLE_NAME%% with some value in the code while installing the script...
If that's really all it's about, then why not just use perl -pie 's/%%VARIABLE_NAME%%/value/g' script.pl? Or s/%%(\w+)%%/$vars{$1}/g? (These are not rhetorical questions)
A search and replace that doesn't parse Perl requires that the search pattern only appears in places where it should be replaced and nowhere else, i.e. it limits what Perl syntax can be used. If that's the case, then one can just as well use e.g. Template::Toolkit (or reinvent that wheel).
As soon as one requires the preprocessing to have even the slightest awareness of Perl syntax, then we're talking about parsing Perl. If you don't believe me, give me an example and I'll give you the counterexample that breaks it ;-)
In the situation you've described, config files or env vars are almost certainly the better solution than editing Perl source code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Prepocessing perl code / substing variables
by nataraj (Sexton) on Apr 15, 2019 at 20:49 UTC | |
by haukex (Archbishop) on Apr 15, 2019 at 21:00 UTC | |
by roboticus (Chancellor) on Apr 15, 2019 at 21:04 UTC | |
by RonW (Parson) on Apr 15, 2019 at 23:23 UTC | |
by nataraj (Sexton) on Apr 17, 2019 at 20:08 UTC | |
by haukex (Archbishop) on Apr 17, 2019 at 21:17 UTC |