in reply to Prepocessing perl code / substing variables
As others have said, what you are trying to do can be done by config files, a simple regex or templates. There is no need to re-invent the wheel or make it square.
Another way is to control your deployment script with command line parameters: deploy.pl --script-name abc --location xyz/abc etc.
And then there are ... autotools (written in Perl I think) which can do variable substitutions to source file templates. I would not use it just for a small task. I am mentioning it because you may want to use it as your main deployment/installation framework and be able to do ./configure && make all && make container && make backup && make push-git. It requires a lot of work to get started with it. Does your use-case justify it?
Here is a skeleton just for the var-sub part (ripped from various sources on the net):
# configure.ac AC_INIT([helloprog],[1.0],[abc@xyz.com]) AM_INIT_AUTOMAKE MYVAR="1234abc" AC_SUBST(MYVAR) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([myscript.pl]) AC_OUTPUT
# Makefile.am bin_SCRIPTS = myscript.pl
Edit (forgot the perl script to have vars substituted):
Edit2 (the name ends in .in denoting a template input, the .pl file will be produced from that. During the configure stage, not the make.):
# myscript.pl.in # all @MYVAR@ will be substituted by value in configure.ac file my $var = "@MYVAR@"; print "var is : $var\n";
bootstrap it using (just once):
aclocal && automake --gnu --add-missing && autoconfand then:
./configure <params> && make allWhen IT people hear autotools, they will almost certainly parrot cmake, gradlew, maven as in a monty pythons sketch. Alas they are serious. Only a true hacker's heart fills with adrenaline when finally reached the state of ./configure && make all. But can you handle it?
bw, bliako
|
|---|