I often forget what I have to change in transfering such code from one site to another so I have an "export" script which takes in templated code and substitutes the variables with site-specific values based on a config. It saves me time and mistakes and satisfies my natural aversion to masochism.

In your case, for example, one could use Template::Toolkit. The templated cgi input file (ABC.in) would be like:

#![% SHEBANG ] # eventually file ABC.cgi use [% LOCATION_OF_VARIABLES_CGI_FILE ]; ...

And this script (verbatim copy from the doc) does the substitutions:

# WARNING: simplistic work flow for demo purposes # create Template object my $template = Template->new({ INCLUDE_PATH => '/search/path', # ... }); # define template variables for replacement my $vars_for_windows = { # whatever a windows path looks like SHEBANG => '#!\...\straw...\perl.exe', LOCATION_OF_VARIABLES_CGI_FILE => 'c:\abc\xyz\variables.cgi', }; my $vars_for_linux = { SHEBANG => '#!/usr/bin/perl', LOCATION_OF_VARIABLES_CGI_FILE => '/usr/xyy/abc/variables.cgi', }; # specify input filename, or file handle, text reference, etc. my $input = 'ABC.in'; if( $target_is_windows ){ # process input template, substituting variables, final output filen +ame $template->process($input, $vars_for_windows, 'ABC.cgi') || die $template->error(); } else { $template->process($input, $vars_for_linux, 'ABC.cgi') || die $template->error(); } print "$0: do you want me to ftp it to remote site?...\n"

bw, bliako


In reply to Re: Success with main page by bliako
in thread Success with main page by traincity

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.