[ back to toc ]

command line parameters

Date: 2002/03/04 16:38

Q:
I would like to pass in some variables via the command line. For example,
I want to be able to run the program the following way.

perl program.pl -u my_username -p my_password

Where the -u switch signifies the following string is the user name and
the -p switch is for their password. Can you help me on how to do this?
A:
it is simple. The command line parameters are in the array @_ thus

$_[0] is '-u'
$_[1] is 'my_username'

and so on

regards,
Peter

[ back to toc ]