package Getopt::Long::Confused; use Regexp::Assemble; sub check { ### Params::Validate::validate_pos(@_,{ type=>HASHREF },{ type=>HASHREF }); my ($option_HREF,$rule_HREF)=@_; my $string=''; my $re=Regexp::Assemble->new(); for my $rule (keys %$rule_HREF) { # Add the regex for this list $re->add($rule_HREF->{$rule}); # Make a copy of our option hash my %option_copy=%$option_HREF; for my $option (split ' ',$rule) { if ($option eq '*') { # Any and all leftovers for my $option (keys %option_copy) { $string.="$option "; } } elseif (exists $option_copy{$option}) { # Add the option's name and remove it from the copy $string.="$option "; delete $option_copy{$option}; }; }; # Separate the rules with a new line $string.="\n"; } ### dump: $string,$re->as_string() if ($string =~ m{$re}m) { return "good!"; } else { return "bad"; }; }; # check: 0**0