Wrong list for naive perl questions revolving around command-line
parameters -- but what the hey... And I hope you're not really trying to
pass command-line parms to a modperl module, 'cause it won't work.
The simplest way is simple the @ARGV array. it contains all the
command-line tokens past the program name (as oppossed to C where argv[0]
contains the program name). Just mosey through the list. It's predefined
for you.
my num_args = @ARGV; # number of command line tokens
my first_arg = $ARGV[0]; # first token
my last_arg = $ARGV[$#ARGV]; # last token
etc...
I'm saying tokens instead of args or parameters beacuse if one of your
parameters is more than one word, such as a person's name, the shell treats
that as two tokens unless it's surrounded by quotes, i.e.,
John Doe -- two tokens
"John Doe" -- one token
If you want to get fancier, look at getopt and getopts which are both part
of the standard perl library. They handle command-line switches, args, etc
and do all the hard work for you.
-- Rob
--On Monday, June 12, 2000 9:37 PM +0330 Ehsan Amiri <[EMAIL PROTECTED]>
wrote:
> Hi all
> I am a naive perl programmer and I have a simple qustion:
>
> How can I pass parameters to my perl program from command-line?
>
> Thanks
> E.A.
>
_ _ _ _ _ _ _ _ _ _
/\_\_\_\_\ /\_\ /\_\_\_\_\_\
/\/_/_/_/_/ /\/_/ \/_/_/_/_/_/ QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __ /\/_/ /\/_/ PROFUNDUM VIDITUR
/\/_/_/_/_/ /\_\ /\/_/ /\/_/
/\/_/ \/_/ /\/_/_/\/_/ /\/_/ (Whatever is said in Latin
\/_/ \/_/ \/_/_/_/_/ \/_/ appears profound)
Rob Tanner
McMinnville, Oregon
[EMAIL PROTECTED]