Re: parsing command line arguments multiple times



On 4/29/05, John Doe <security.department@xxxxxxxx> wrote:
>
> Am Freitag, 29. April 2005 09.19 schrieb lohit:
> > On 4/29/05, lohit <lohit.vijayarenu@xxxxxxxxx> wrote:
> > > Hi,
>
> Hi
>
> > > i have a requirement, as in based on one command line option, the rest
> > > of the arguments change for the same script.
> > > eg: script could be called in either of the ways
> > > script1 -option1 -option2 adfas -option3
> > > script -option1 -option4
> > > my question is
> > > 1. how do we get the option1 alone from GetOptions function
> > > 2. can i call GetOptions multiple times?
> > > how would you handle such situation
> > > thanks in advance for the help!!
> >
> > ok, i see that only one option could be parse with GetOptions
>
> Are there reasons not to use GetOpt::Std or GetOpt::Long?
> Could you provide some code?

i am fine with any GetOpt as long as it solves my problem. this is the
problem i have been having.
script usage is:
script.pl -checkflag -option1 value1 -option2 value2
now my problem is i need to check only '-checkflag' flag. rest would be
parsed in second run.
now if the first run i parse it something like
&GetOptions('checkflag' => \$check_flag);
if ($checkflag)
{
do somethign here.....
}
but perl throws an error,
Unknow argument option1
Unknow argument option2
how do i get rid of them, or any other solution?
thanks!

> and for the
> > next run i could copy back a saved version of @ARGV.
> > but while i am processin any one options, i get an error message saying
> > *Unknow option* * *for the other unused options. how do i get rid of
> this?
>
> joe
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>


Relevant Pages