perl 模块Getopt::Long使用示例
use strict; use warnings; use Getopt::Long; my @ARGV2 = @ARGV; my $leng =10; my $data ="x.txt"; my $verb; my $help; die("error in options") unless GetOptions( "l|length=i" => \$leng, "f|file=s" => \$data, "v|verbose" => \$verb, "h|help" => \$help, ); sub usage { print <<USAGE -l|--length <number> set number of length -f|--file <str> set name of files -v|--verbose set verbose -h|--help show this help information USAGE } if($help || @ARGV2 == 0){ exit 0 if &usage(); } print "$leng\n$data\n$verb";
标签:set,help,Long,Getopt,my,verbose From: https://www.cnblogs.com/mmtinfo/p/17789273.html