zycchen 发表于 2015-12-28 08:21:01

perl Getopt::Long的用法

  getopt.pl
  #!/usr/bin/perl -w
  use strict;
  use Getopt::Long;
  use YAML::XS;
  use Carp;
  my %option;
  croak "Error:Getopt::Long::GetOptions\n" unlessGetopt::Long::GetOptions(\%option, 'h|help', 's|server', 'p|port');
  #my @options = qw /l|length=i f|file=s v|verbose/;#用数组表示,数组元素不能用引号
  #croak "Error:Getopt::Long::GetOptions\n" unlessGetopt::Long::GetOptions(\%option, @options);
  
  print YAML::XS::Dump %option;
  
  ./getopt.pl -p 12345
  --- l
--- 12345
页: [1]
查看完整版本: perl Getopt::Long的用法