#!/use/bin/env perl use Getopt::Long; use Getopt::Long::Confused; GetOptions(\my %h ,qw(a:s b c d) ,qw(e=s f g h) ,qw(i:o j k l m n) ,qw(o=o p q r s t) ,qw(u:f w x) ,qw(y=f z) ); my %option=( # after placing options in this order # => check with this regex 'a b c d *' => '^a( [bcd]) $' # a requires one of b, c or d ,'e f g h *' => '^e( [fgh])? $' # e requires at most one of f g or h ,'i j k l m n *' => '^$' # don't allow i and o options ,'o p q r s t *' => '^$' # in this example ,'u v w x *' => '^u( v)|( w x) $' # u requires v OR w and x ,'y z *' => '^y z $' # y requires z ); if (my $warning=Getopt::Long::Confused::check(\%h,\%option)) { die $warning; } ### 'done!' exit;