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
  • 22,579
  • 65
  • 193
  • 321
  • 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
  • 367,544
  • 15
  • 269
  • 518
ysth
  • 96,171
  • 6
  • 121
  • 214