| [SOLVED] Using $ARGV[1] in PERL to open any text file for this program.? How can I use $ARGV[1] in replace of 'data.txt' or something like $ARGV[1] in this code:
# PRO1.pl
open (MYFILE, 'data.txt');
while (<MYFILE>) {
chomp;
print "$_\n";
}
close (MYFILE);
so that I can run any text file in this program.
For example
$ perl PRO1.pl part1.txt
$ perl PRO1.pl part2.txt
$ perl PRO1.pl part3.txt
Do I have to change this code completely, or can I do something like replace 'data.txt' with '$ARGV[1]'. |