0
在我不太明白的Perl脚本中出现一些奇怪的行为。我试图将我的一些魔术字符串文字变成可以更容易修改的变量。当我使用变量而不是字符串文字时,Perl方法失败
我在我的子程序中有一个参数叫做$in_feature
。现在它的价值仅仅是"in_feature"
。我可以打印出来,看起来很好。到目前为止好...
此代码失败,虽然:
if ($in_feature != "" && !$blockModel->is_field($in_feature))
{
print "ERROR: was expecting to find a variable in the block model called $in_feature.\n";
return;
}
如果我删除字符串比较和变更方法调用返回字符串字面它按预期工作。
if (!$blockModel->is_field("in_feature"))
{
print "ERROR: was expecting to find a variable in the block model called $in_feature.\n";
return;
}
所以变量是某种方式的字符串,它等于空字符串,并且不能用来代替字符串?!?这是为什么?在Perl
谢谢,我认为就是这样。 PERL真是太讨厌了嘿:( – Coxy
@Coxy,它拼写为“Perl”,如果你使用'use warnings',它会大声警告这个,如你应该的。 – ikegami