【问题标题】:What's the meaning of plain string when using as condition? [duplicate]使用 as 条件时,纯字符串的含义是什么? [复制]
【发布时间】:2015-03-22 03:18:18
【问题描述】:

perl one-liner 下输出 hello 到控制台,那么这里的 false 不是变量也不是字面字符串怎么解释呢?

perl -e"if (false) {print 'hello'}"

【问题讨论】:

  • use warnings;perl -we "if (false) {print 'hello'}"

标签: perl


【解决方案1】:

在 Perl 中,假为真。唯一被评估为假的术语是:

0, '0', '', (), (''), undef

FALSE/TRUE 不是布尔值。它们被称为barewords,使用use strict;,它甚至不会运行。

【讨论】:

    【解决方案2】:

    来自http://perldoc.perl.org/perldata.html

    空话

    将处理语法中没有其他解释的单词 好像它是一个带引号的字符串。这些被称为“裸词”。

    【讨论】:

      猜你喜欢
      • 2012-10-25
      • 2012-04-02
      • 2015-10-20
      • 2015-08-01
      • 1970-01-01
      • 2018-02-15
      • 2012-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多