We don't bite newbies here... much | |
PerlMonks |
Prepocessing perl code / substing variablesby nataraj (Sexton) |
on Apr 15, 2019 at 18:32 UTC ( [id://1232596]=perlquestion: print w/replies, xml ) | Need Help?? |
nataraj has asked for the wisdom of the Perl Monks concerning the following question: Hi! I have some script (i.e. backup script) that should work in different containers, do same job, but use different parameters in each container... like
I want to put this script into git, so I do not know how to deal with paramethers that should be different in each container... My idea was to change values to some substitution instructions and use some preprocessor that will do the substitution. Like
and then create a small deploy script that has container specific configuration and just do preprocessing and installation. Like do_preprocess("my_scripl.PL","/srv/msp/my_script.pl",{NAME=>"my_second_project",DIR=>"/srv/msp"});So whenever I update my backup script and put it to git I can just git pull at the container, and run this installation script, and everything will continue working as before, but with new script version. For variable substitution it is good to use some standard module. I guess I am not the first person who needs this. I carefully looked at the modules listed at https://metacpan.org/pod/distribution/Text-PerlPP/bin/perlpp in section ALTERNATIVES, but I did not like any of them. They are too old, or too new, part of some other project that have nothing in common with var substitution. These modules are not used in other modules and they are not part of debian (that is bad for me too) Theoretically I can write Text::YetAnotherPP but there is a chance to get another unsupported module this way... What is the right way to deal with my simple task? What would you advice?
Back to
Seekers of Perl Wisdom
|
|