passing parameters to a perl prgram using getopts

V

vabby

Hi
I have to pass certain parameters to a perl program like if log file is
required or not, wot process is to be setup and the mode. I ahve
written the following script, named bat.pl
use Getopt::Std;

use vars qw($opt_p $opt_m $opt_l);
getopts("p:m:l");
my $process = uc($opt_p) || usage();
my $mode = uc($opt_m) || usage();
my $logging = uc($opt_l) ;
print "\n the value of process is $process\n";
print "\n the value of mode is $mode\n";
print "\n the value of log is $logging\n";
exit(1);

so i invoke the program this way
bat -p Ipc -m qa -l N


my problem is that, whatever the value of the 3rd parameter I pass,
the $logging variable gets the value of 1. This is again true if a
reduce the number of variables to be passed to 2 , then the last
variable again gets the value of 1, irrespective of whatever I pass.

tx
vabby
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top