Programming C# C++ (7) Delphi (618) Java (8) JavaScript (30) perl (9) mysql (3) perl CGI (3) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
|
Reading command line arguments from perl
7 comments. Current rating: (4 votes). Leave comments and/ or rate it.
Question: I am writing some command line tools to manipulate a large number of text files. How can I pass commandline arguments?
Answer: The command line can be read with @ARGV
 | |  | | #!/usr/bin/perl
$numArgs = $#ARGV + 1;
print "$numArgs command-line arguments.\n";
foreach $argnum (0 .. $ print "@ARGV[$argnum]\n";
} | |  | |  |
Comments:
|
|
|
|
Doesn't address what happens if there are no args provided.
|
|
|
|
|
Doesn't address what to do with the arguments once you read them
|
|
|
|
|
if no args then it is -1+1=0....
|
2008-02-11, 02:57:05 (updated: 2008-02-11, 02:57:51) |
|
|
|
|
|
|
|
|
It's probably going to work anyway, but shouldn't it be $ARGV[ $argnum]?
|
|
|
|
|
please RTFM
|
|
|
|
|
Don't pay attention to the haters. This is exactly what I needed. Short & right to the point. THANKS!
|
|