===== Here's the file prog_file#!/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);
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 \$APPNAME="AnyName"; print "This is the var \$APPNAME and this is what needs to get substit +uted $APPNAME\n";
It somewhat works but not exactly, seems to be a catch 22 built in here. Thanks for any and all help in advance...#!/usr/bin/perl # Sample Program print "This is the var $APPNAME and this is what needs to get substitu +ted AnyName\n";
In reply to Perl Script to write a perl script by electroman00
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |