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


In reply to Getopt::Long via. Hashes by librarat

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.