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, 2752👍, 0💬
Popular Posts:
How do you open an SSH connection to a remote box? ????
How To Process Query Result in PL/SQL? - Oracle DBA FAQ - Introduction to PL/SQL You can run queries...
What is the purpose of Replication ? Replication is way of keeping data synchronized in multiple dat...
Why is it preferred to not use finalize for clean up? Problem with finalize is that garbage collecti...
Why is there extra white space before or after tables? This is often caused by invalid HTML syntax. ...