![]() |
|
The stupid question is the question not asked | |
PerlMonks |
Re: Dynamic optionby ELISHEVA (Prior) |
on Mar 16, 2011 at 05:37 UTC ( #893498=note: print w/replies, xml ) | Need Help?? |
I'm not exactly clear what you mean by "user input" since the entire command line is "user input" - do you mean that you have an option that can be assigned an arbitrary number of values? If so, you can do something like this on the command line:
And in your getopt definition, you would add, "input=s@" instead of "input=s". Alternatively, you could allow your users to assign a comma delimited list (no internal spaces), like this:
That would add an extra processing step: just in case someone used the first syntax (multiple options), you would concatenate the options with a comma to form one long comma delimited list. Then you would split the long list back into individual options. Like this (note: pseudocode - might have typos):
If you've learned about Getopt::Long from reading code examples, you might want to take a look at the Getopt::Long documentation. It has a fair bit of discussion about how to have multi-valued options and some examples. Multivalued command line arguments have been supported by the version that ships with Perl since at least 5.8.8
In Section
Seekers of Perl Wisdom
|
|