my $pmum=0;
my $argc = scalar( @ARGV );
if ( $argc < 2) {print "/n/te.g. upload_rec_v2.pl -server taibei/n"; exit 100; }
my $srvName="";
foreach (@ARGV)
{
print "the $pmum is : $_/n";
if ($_ =~ /^/-server$/i) {
if ( ($pmum +1 ) > $argc-1) {print "invalid argument. can not find server name/n"; exit 1;}
$srvName .= $ARGV[$pmum+1];
}
$pmum++;
}#foreach
if ($srvName eq "") { print "invalid argument. can not find server name/n"; exit 2;}
print "Server Name: $srvName/n";
#end
调用方法:XXX.pl -server taibei