Getopts to flag bad options without dash
问题 Getopt::Long::Configure("no_pass_through"); my %opts = (); GetOptions(\%opts, 'opt1=s', 'opt2=s', 'opt3' ); test.pl bad_option_without_dash How do I make getopts flag an error when a bad option is passed without a dash? I was expecting that no_pass_through will take care of this. What am I missing? 回答1: Getopt::Long just extracts the options. It's up to you to validate the value of those options and the non-option arguments (which are left in @ARGV ). Specifically, if you want to make sure