Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How do I read command-line arguments with Perl?
How do I read command-line arguments with Perl?
✍: Guest
With Perl, command-line arguments are stored in the array named @ARGV.
$ARGV[0] contains the first argument, $ARGV[1] contains the second argument, etc.
$#ARGV is the subscript of the last element of the @ARGV array, so the number of arguments on the command line is $#ARGV + 1.
Here's a simple program:
#!/usr/bin/perl
$numArgs = $#ARGV + 1;
print "thanks, you gave me $numArgs command-line arguments.\n";
foreach $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum]\n";
}
2013-09-19, 2702👍, 0💬
Popular Posts:
How Large Can a Single Cookie Be? - PHP Script Tips - Understanding and Managing Cookies How large c...
What is the quickest sorting method to use? The answer depends on what you mean by quickest. For mos...
Is Session_End event supported in all session modes ? Session_End event occurs only in “Inproc mode”...
What is the quickest sorting method to use? The answer depends on what you mean by quickest. For mos...
How To Merge Values of Two Arrays into a Single Array? - PHP Script Tips - PHP Built-in Functions fo...