English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Say my code is:
# PRO1.pl
open (MYFILE, 'data.txt');
while () {
chomp;
print "$_\n";
}
close (MYFILE);

But I want to run all these from this PRO1.pl program

$ perl PRO1.pl part1.txt
$ perl PRO1.pl part2.txt
$ perl PRO1.pl part3.txt

What do I change 'data.txt' so I can use any text file with this program.

2007-03-21 01:26:27 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

'data.txt' is a string representing the file name.
This can be changed to a variable
$fileName='data.txt'
open (MYFILE, $fileName);

So now you have a variable in the open command you just have to figure out a way to get a parameter into the program so that it will open the parameter file and not the variable file.

2007-03-21 03:13:07 · answer #1 · answered by AnalProgrammer 7 · 0 0

One answer could be to create a report containing the names of documents to be processed via this technique. the innovations report used as a parm on the command line might grant this technique with a itemizing of documents to be processed. Open that report, examine the names of the documents into an array, close the report, and then open and technique the documents named interior the array.

2016-10-19 06:03:19 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers