vish has asked for the wisdom of the Perl Monks concerning the following question:
I was trying to read the file name & processid using the Getopt.
I will get $sFile as the inputfilename that I give. But why the $iPid will be 1 always when I run the perl script as:#!/tools/opt/bin/perl -w use Getopt::Std; $iPid = 0; $sFile=""; $Getopt::Std::opt_f = ""; $Getopt::Std::opt_p = 0; getopts('f:p'); if($Getopt::Std::opt_f) {$sFile= $Getopt::Std::opt_f;} if($Getopt::Std::opt_p) {$iPid = $Getopt::Std::opt_p;} print "\n sFile--> $sFile"; print "\n iPID-->$iPid\n";
Can I give the options -f -p in any order? If there are many options also will the order matters? Help me..perl <perlfilename> -f <inputfilename> -p <ProcessID>
Then if I want to read the PID which I provide as an numeric argument along with -p option , the code should be changed as?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt in perl
by moritz (Cardinal) on Jan 20, 2009 at 08:07 UTC | |
|
Re: Getopt in perl
by Anonymous Monk on Jan 20, 2009 at 08:03 UTC |