Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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 && autoconf

and then:

./configure <params> && make all

When 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


In reply to Re: Prepocessing perl code / substing variables (kraken released!) by bliako
in thread Prepocessing perl code / substing variables by nataraj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-03-28 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found