What do Perl functions that return Boolean actually return

后端 未结 4 927
名媛妹妹
名媛妹妹 2020-12-06 11:02

The Perl defined function (and many others) returns \"a Boolean value\".

Given Perl doesn\'t actually have a Boolean type (and uses values like 1 for t

4条回答
  •  没有蜡笔的小新
    2020-12-06 11:33

    They return a special false value that is "" in string context but 0 in numeric context (without a non-numeric warning). The true value isn't so special, since it's 1 in either context. defined() does not return undef.

    (You can create similar values yourself with e.g. Scalar::Util::dualvar(0,"").)

提交回复
热议问题