Regarding the conflict between options... perhaps this (KISS in play):-

# to check on conflicting switches use Getopt::Std; # Switches and Invalid combinations # NOTE: conflicts must be specified in alphabetical order! @switches = (); # List of supplied switches @switch_conflicts = ( "lp", # portrait and landscape "lpv", # portrait, landscape, view-only "pv" # portrait, view-only ); # ---------- getopts("plv"); # ---------- Specify switches on CLI if (defined($opt_p)) { push(@switches, "p"); } if (defined($opt_l)) { push(@switches, "l"); } if (defined($opt_v)) { push(@switches, "v"); } $switch_list = ""; foreach $item (sort @switches) { $switch_list .= $item; } # ------ foreach $item (@switch_conflicts) { if ($switch_list =~ /$item/) { # Get out at earliest opportunity printf("\nERROR: Invalid combination of switches, /%s/\n", $ite +m); die("\n"); } } printf("\nSwitches are all Ok.\n"); exit(0);

The main thing with doing things this way is that it's relatively simple to add a new switch (and its conflicts), update the 'getopts()' string and add an additional (basic) 'opt_x'... and it should be easy enough to turn this whole thing into a sub{} or similar...

Any other thoughts?

Fanx! again for all the posts... and I'm still pondering the switch checking/function execution side of things...


In reply to Re: How do I process many (conflicting) command line parameters? by ozboomer
in thread How do I process many (conflicting) command line parameters? by ozboomer

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.