我如何使用布尔变量在Perl? [英] How do I use boolean variables in Perl?
本文介绍了我如何使用布尔变量在Perl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我曾尝试:
$ VAR = FALSE;
是$ var = FALSE;
是$ var = FALSE;
这些工作都不是。我得到的错误讯息
裸词假不允许的,而严格潜艇正在使用中。
解决方案
在Perl中,以下评估为false条件语句:
0
'0'
民主基金
''#空标
()#空列表
('')
其余都是如此。还有无裸字真正
或假
。
I have tried:
$var = false;
$var = FALSE;
$var = False;
None of these work. I get the error message
Bareword "false" not allowed while "strict subs" is in use.
解决方案
In Perl, the following evaluate to false in conditionals:
0
'0'
undef
'' # Empty scalar
() # Empty list
('')
The rest are true. There are no barewords for true
or false
.
这篇关于我如何使用布尔变量在Perl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文