Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Dynamic option

by Anonymous Monk
on Mar 16, 2011 at 06:45 UTC ( #893506=note: print w/ replies, xml ) Need Help??


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

To explain again ,the ones in "[]" are optional sub-options(they may or may not present always) to the values of "input"option, data,modem,apps are values to option "input",they can also change.

EXAMPLE:- findfiles -input [-nd -na ] data [-nc -nd] modem apps -des "finding fi +les" -r 1000 Basically ,pseudco code of what I want to achieve is below.Really appr +eciate if someone can give me the perlversion of the code. for each "input option value" { call function A if not exits nd call function B if not exits na call function C if not exists nc }


Comment on Re^4: Dynamic option
Download Code
Re^5: Dynamic option
by ikegami (Pope) on Mar 16, 2011 at 11:08 UTC

    So? If the value is optional, tell Getopt::Long it's optional.

    --input --input=nd --input=na --input=nd,na
Re^5: Dynamic option
by JavaFan (Canon) on Mar 16, 2011 at 12:21 UTC
    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.

      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://893506]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-09-20 22:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (163 votes), past polls