rockstar1492 has asked for the wisdom of the Perl Monks concerning the following question:

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?

Replies are listed 'Best First'.
Re: command line variables
by japhy (Canon) on Mar 04, 2002 at 15:49 UTC
    You can use a module like Getopt::Std or Getopt::Long, or you can use the -s switch to Perl, and run your program as perl -s program.pl -u=foo -p=bar, which will set $main::u to "foo" and $main::p to "bar".