Hi all.....
Trying to write a perl script that will write a perl script.
===== Here's my test prog test.pl
#!/usr/bin/perl
# External Modules
#use strict;
#use warnings;
use Cwd;
system "clear";
$cwdir = cwd;
$APPNAME="AnyName"; # << "AnyName" must substitute in prog_file below.
#require "$cwdir/prog_file";
open(PROGFILE, "<$cwdir/prog_file"); # open for input
#my(@lines) = <PROGFILE>; # read file into list
@lines = <PROGFILE>; # read file into list
#my($line);
foreach $line (@lines) # loop thru list
{
print "$line";
}
close(PROGFILE);
===== Here's the file prog_file
#!/usr/bin/perl
# Sample Program
\$APPNAME="AnyName";
print "This is the var \$APPNAME and this is what needs to get substituted $APPNAME\n";
The output needs to be the prog_file with only the second $APPNAME in the print line substituted by the var in the test.pl
So the output looks like this....
#!/usr/bin/perl
# Sample Program
print "This is the var $APPNAME and this is what needs to get substituted AnyName\n";
It somewhat works but not exactly, seems to be a catch 22 built in here.
Might add I'm running out of brain cells due to this problemo.
Thanks for any and all help in advance...