Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The hash was from the program I was testing, since the hash would be a blessed object holding, among other things, a 'range' for the acceptable number of parameters that could be entered.

I.e. If I have a switch or option parser, say for the command line, and you want to have one option that can take 0 or more parameters, what would be a good syntax for specifying that?

I was looking at the syntax of the range operator as a possible model for such an option, which is why I think I said I was playing around with the range syntax -- trying to think what my needs were, and how to make such a specification intuitive and useful.

While the hash might not be directly useful, having the range specified in a dynamic array would be, as collected input could be stored there. Simply listing options for range syntax doesn't give me a feel for how such would be included in a data structure.

If you put your examples into an array with other specifications named in a hash. Your examples might look more like what I was working with if you had them in a {}, since instead of (or in addition to), I have thought about specifying a min/max (but that didn't feel right) as well as one or more functions for validation and/or processing of the options on-input and perhaps for specifying a stopping condition.

I mentioned that I used an alias -- because, at least while playing, I often start with 1-liners, or "few-liners" to get an idea on how something might look or might work.

I hit the "-1" example when thinking about a way to specify "no maximum" # of params. Even specifying 0..5... looking at it I think 0 to 5 params (i.e. having no args would be ok too), but that's really not what that notation means...(*sigh*)

Note: I'm not asking folks to solve that problem, just giving the context of how I ran into this and the reason for the form of the problem.


In reply to Re^2: curious behavior: why does it do this? by perl-diddler
in thread curious behavior: why does it do this? by perl-diddler

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?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found