# 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", $item); die("\n"); } } printf("\nSwitches are all Ok.\n"); exit(0);