dukea2006 has asked for the wisdom of the Perl Monks concerning the following question:
Total Newbie Question: How do I pass a file name as a command line argument? I am currently successfully passing the file name in the Open function:
#!/usr/bin/perl use warnings; use strict; open(FILE1,"testData.txt ")or die ("Unable to open the file.");
The above code works great - I can open the file load the data into an array and I'm good to go. The only issue is every time I want execute it against a different data file, I have to edit my Perl code. I'd rather pass the file name at the command line to make things more dynamic.
Again, this feels like a total newbie question (probably because that is my current skill level) but I haven't been able to find much on how to accomplish this. I read through the input \ output tutorials and I'm still in need of help.
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Opening a File from the Command Line
by almut (Canon) on Apr 06, 2010 at 21:11 UTC | |
|
Re: Opening a File from the Command Line
by FunkyMonk (Bishop) on Apr 06, 2010 at 21:15 UTC | |
|
Re: Opening a File from the Command Line
by 7stud (Deacon) on Apr 06, 2010 at 21:57 UTC | |
by FunkyMonk (Bishop) on Apr 07, 2010 at 00:17 UTC |