Entry
Perl: Command: Line: Parameter: How to print all command line parameters?
Sep 7th, 2009 04:28
Knud van Eeden, Joe Bloggs, Rich Pasco
----------------------------------------------------------------------
--- Knud van Eeden --- 25 December 2004 - 05:02 am -------------------
Perl: Command: Line: Parameter: How to print all command line
parameters?
---
Use the $ARGV array, which contains by design all command line
parameters. It starts with 0, and ends at $#ARGV
===
Steps: Overview:
1. -Create a Perl file (e.g. 'test.pl') containing text
similar to the following
--- cut here: begin --------------------------------------------------
my $I = 0;
my $minI = 0;
my $maxI = $#ARGV;
#
for ( $I = $minI; $I <= $maxI; $I++ ) {
print( "$ARGV[ $I ] \n" );
}
--- cut here: end ----------------------------------------------------
2. -On the MSDos command line type the command
perl <your perl filename> <your parameter1> <your parameter2> ...
e.g.
perl test.pl myparameter1 myparameter2 myparameter3
shows the lines
myparameter1
myparameter2
myparameter3
===
Internet: see also:
---