librarat has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks!
I'm working with Longops on a project, but given the sheer number of options in the code I'm writing, I've managed to get myself confused. Seen in the snippet below is a sample of "options", each one acting a little different.
'add-domain|ad=s', # Add a domain. -n and -t are optional -ad 'do +main.com' -n 'Note like this' -t
This action can either be called with "-ad", "-ad -n", or "-ad -n -t", or "-ad -t" (each one obviously having a value). "-ad" is the actual action, -t and -n are supplementary to -ad.
'show-domains|sd', # Show all domains and their IDs -sd
The above action can only be called with "-sd". It takes no value (its a bool)
My question, and I guess my confusion, too is in the best way to go about getting parameters, sanitizing them, and validating their ability to go together. There are a total of about 30 different (and unique) options, some taking a value, some that are just bools.
Currently, I'm using a hash via GetOptions (\%options, and am just looking for values.
Cheers!
Libby
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getopt::Long via. Hashes
by vsespb (Chaplain) on May 26, 2013 at 18:07 UTC | |
by librarat (Novice) on May 26, 2013 at 19:11 UTC | |
by vsespb (Chaplain) on May 26, 2013 at 19:19 UTC | |
|
Re: Getopt::Long via. Hashes
by karlgoethebier (Abbot) on May 26, 2013 at 19:53 UTC | |
by vsespb (Chaplain) on May 26, 2013 at 20:03 UTC | |
by Jim (Curate) on May 27, 2013 at 02:00 UTC | |
by vsespb (Chaplain) on May 27, 2013 at 07:11 UTC | |
|
Re: Getopt::Long via. Hashes
by Anonymous Monk on May 27, 2013 at 07:42 UTC |