perl取得用户输入命令行参数

usage: getcmd.pl command –key=value ……..

#!/usr/bin/perl
#  
use strict;
 
my $cmdline;
foreach my $c (@ARGV){
                $cmdline.=$c;
}
print $cmdline,"\n";
 
my @list=split(/--/,$cmdline);
print "LIST[0]: $list[0]\n";
print "CMD:",shift @list,"\n";
 
foreach my $c (@list){
                if ($c =~/(\S+)=(\S+)/){
                                print "K=$1, V=$2\n";
                        }
}
shells/program/perl/perl-get-params.txt · 最后更改: 2011/01/31 01:34 由 狐狸
[unknown link type]到顶部
GNU Free Documentation License 1.3
京ICP备05034962号 Debian Driven by DokuWiki get firefox browser Recent changes RSS feed Valid XHTML 1.0