1

Below perl one-liner outputs hello to console, so how is false interpreted here since it is not a variable or literal string?

perl -e"if (false) {print 'hello'}"
Thomson
  • 19,332
  • 23
  • 82
  • 128

2 Answers2

5

In Perl false is true. The only terms that are evaluated as false are:

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

FALSE/TRUE are not boolean values. They are called barewords and with use strict;, it will not even run.

Hameed
  • 2,154
  • 1
  • 20
  • 30
4

From http://perldoc.perl.org/perldata.html

Barewords

A word that has no other interpretation in the grammar will be treated as if it were a quoted string. These are known as "barewords".

Michael Burr
  • 321,763
  • 49
  • 514
  • 739