hitl 发表于 2015-12-27 07:30:10

perl处理命令行参数

  使用Getopt::std模块
  代码如下



use strict ;
use Getopt::Std ;
sub test{
    use vars qw($opt_d $opt_f) ;
    getopts('d:f:') ;
    print $opt_d, "\n" ;
    print $opt_f, "\n" ;
}
&test() ;
1 ;
  'd:f:' d和f后面有冒号,表示-d和-f后面必须跟参数。
  对于更复杂的命令行参数处理,请看Getopt::long模块。
  
页: [1]
查看完整版本: perl处理命令行参数