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" unless Getopt::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" unless Getopt::Long::GetOptions(\%option, @options);

 

print YAML::XS::Dump %option;

 

./getopt.pl -p 12345

--- l
--- 12345

posted @ 2012-12-04 11:08  Arya_yu  阅读(380)  评论(0编辑  收藏  举报