For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > February 2007 > Prob with GetOptions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Prob with GetOptions
Aakash Sudhanwa

2007-02-21, 7:57 am

Hello All,
I am writing a script wherein its usage is as follows :
mkelem [-h] [-dir [-rec]] <element name1> <element name2>

Now for this i have used the GetOptions module as follows :
$st = GetOptions("h|help" => \$help,
"dir=s" => \$dir,
"rec" => \$rec);
The script when executed with-dir option followed by an argument should go
to one part of the script as in :
mkelem -dir a b c
And the script executed with option -dir and -rec should do some other part
as in (which doesnt happen):
mkelem -dir -rec a b c
As i am using getopts module with "-dir=s", it is taking the -rec as its
argument and it doesnt consider it as an option (which i think is natural
with "dir=s") .
Also i do not want to use -rec option alone i.e. it is to be used either
with -dir option or not used at all.

Is this possible ???

Regards
Aakash


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com