我正在从批处理中调用 perl 脚本并提供适当的参数,它应该返回 1、2、3 或 4。但事实并非如此。我从命令行检查了 Perl 的输出,它们输出了正确的结果,我认为它在批处理语法中
批:
@echo off
setlocal enabledelayedexpansion
FOR /F "delims=*" %%I IN ('Perl C:/ExecutionSDKTest_10.2.2/TestProp1noRefCheck.pl 844') DO set lineCase=%%I
echo line case is !lineCase!
珀尔:
use strict;
use warnings;
sub main1;
my $arg1 =shift;
main1($arg1);
exit;
sub main1
{
#Returns 1,2,3 Depending on testNum passed
my @gp1= (829,845,851,859,864,867);
my @gp2= (861,863,865);
# my @gp4= (826-828,830-839,843-844,847-850,852-854,860-862,883);
# my @gp3= (877-882,884);
my $val1=1;
my $val2=2;
my $val3=3;
my $val4=4;
if((grep /^$arg1$/,@gp1) || ($arg1 >=822 && $arg1<=824))
{
# print "$val1\n";
return $val1;
} elsif ((grep /^$arg1$/,@gp2) || ($arg1>=855 && $arg1<=858))
{
#print "$val2\n";
return $val2;
} elsif (($arg1==884) || ($arg1>=877 && $arg1<=882))
{
#print "$val3\n";
return $val3;
} else
{
#print "$val4\n";
return $val4;
}
}