Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: 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:

findfiles --input=data --input=modem --input=apps -des "finding files" + -r 1000

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:

findfiles --input=data,modem,apps -des "finding files" -r 1000

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):

my @input = split(/,/, join(',', $options{input}))

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 reply to Re: Dynamic option by ELISHEVA
in thread Dynamic option by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2023-10-03 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?