First, thanks for the responses.
After posting this I did do further research and found HTML::Template.
Not sure it's what I'm looking for though.
The code I provided was an example of the task at hand.
Basically, it's to take a perl script and treat it as a flat text file and read it in substituting the vars as needed from the perl script creator.
I do have a working bash script that was very easy to make.
#!/bin/bash
APPNAME="AnyApp"
screen=1
if [! screen ]; then
{
cat > /tmp/new_prog_file << EOF
}
else
{
cat << EOF
}
print "This is the var \$APPNAME and this is what needs to get substit
+uted $APPNAME\n";
EOF
Works a treat with little effort (max efficiency) the goal.
However perl seems to be a cronic complainer.
It seems from tests so far the only way to get perl to sub the vars is to make prog_files an include, then perl complains about everything in prog_files.
As a note....
\$APPNAME results in $APPNAME....
$APPNAME results in AnyApp....
Bash just eats, digests and spits out the result.
Simple, my favorite method KISS.
Now I also tried the equiv in perl....
#!/usr/bin/perl
$APPNAME="AnyApp"
require "prog_file.lib";
read_prog
prog_file.lib
sub read_prog
print <<"EOF";
print "This is the var \$APPNAME and this is what needs to get substit
+uted $APPNAME\n";
EOF
1;
The problem is getting an "if" to print to screen or to a file to work, either from the require sub or from the perl creator prog.
Easy using bash, not so with perl....at least not for me.
My mind is already boggled by the var substitutions that needed to be done throughout.
Solved the var boggle issue using a var naming convention.
Thanks in advance... |