1
print "Result: " . (0 == 1); # Result:
print "Result: " . (1 == 1); # Result: 1

Why does perl output an empty string for a false value and not 0?

CJ7
  • 21,593
  • 63
  • 183
  • 312
  • 2
    Possible duplicate of [Why does !1 give me nothing in Perl?](http://stackoverflow.com/questions/1134962/why-does-1-give-me-nothing-in-perl) and http://stackoverflow.com/questions/3914129/why-does-perl-use-the-empty-string-to-represent-the-boolean-false-value?rq=1 – Thilo Sep 06 '16 at 01:20

1 Answers1

3

Because in Perl, the false value returned by many operators and builtins is a special value that is 0 in a numeric context and '' in a string context.

ikegami
  • 343,984
  • 15
  • 249
  • 495
ysth
  • 92,097
  • 6
  • 117
  • 207