Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: Dynamic option

by JavaFan (Canon)
on Mar 16, 2011 at 12:21 UTC ( #893535=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Dynamic option
in thread Dynamic option

As the author of Getopt::Long always says, options are optional, or they wouldn't be options. So the "they may or may not be present" isn't anything special. In fact, it's the bread and butter of Getopt::Long - it only deals with things that may or may not be present.

If you make the call syntax like:

findfiles --input data modem apps --nd --na --nc --des "..." -r 1000
Something like:
GetOptions 'input=s{0,}' => \my @input, 'na' => \my $na, 'nd' => \my $nd, 'nc' => \my $nc, 'des=s' => \my $des, 'r=i' => \my $r;
Should do the trick.


Comment on Re^5: Dynamic option
Select or Download Code
Re^6: Dynamic option
by ikegami (Pope) on Mar 16, 2011 at 15:04 UTC

    That's not what the OP wants. He wants to be able to specify 'nd' for -input (or not), and again for data (or not).

    Your solution only permits specifying it once (although it could be changed to counted), and it's not associated with "input" or "data".

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://893535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-12-19 23:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (94 votes), past polls