electroman00 has asked for the wisdom of the Perl Monks concerning the following question:
===== 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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Script to write a perl script
by almut (Canon) on Dec 02, 2009 at 20:30 UTC | |
|
Re: Perl Script to write a perl script
by Limbic~Region (Chancellor) on Dec 03, 2009 at 03:12 UTC | |
by electroman00 (Novice) on Dec 03, 2009 at 15:40 UTC | |
by electroman00 (Novice) on Dec 04, 2009 at 18:07 UTC | |
by Corion (Patriarch) on Dec 04, 2009 at 18:18 UTC | |
|
Re: Perl Script to write a perl script
by ikegami (Patriarch) on Dec 02, 2009 at 22:29 UTC | |
|
Re: Perl Script to write a perl script
by leocharre (Priest) on Dec 02, 2009 at 20:49 UTC |