我刚刚回到 Perl 编程,所以如果这是一个简单/愚蠢的问题,我表示歉意。
我的 If 语句返回 true(永远不会去 else),我不确定为什么。例如,此代码从不打印“getshere”:
@showName = ("Matt","Matt","Matt","Gym","Gym");
$counter=0;
foreach (@showName)
{
if ($showName[$counter]==$showName[$counter+1])
{
print "$showName[$counter] equ $showName[$counter+1]\n";
}
else
{
print "getshere";
}
$counter++;
}
你能告诉我我做错了什么吗?
谢谢!