Getopts to flag bad options without dash

前端 未结 3 711
再見小時候
再見小時候 2021-01-22 11:35
Getopt::Long::Configure(\"no_pass_through\");
my %opts = ();
GetOptions(\\%opts,
           \'opt1=s\',
           \'opt2=s\',
           \'opt3\'
          );
         


        
3条回答
  •  被撕碎了的回忆
    2021-01-22 12:31

    Options are denoted with a leading dash (hyphen); arguments are not.

    You might find Getopt::Long Argument-callback useful:

    A special option 'name' <> can be used to designate a subroutine to handle non-option arguments. When GetOptions() encounters an argument that does not look like an option, it will immediately call this subroutine and passes it one parameter: the argument name.

提交回复
热议问题