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
  • 20,586
  • 28
  • 90
  • 134

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,227
  • 1
  • 21
  • 31
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
  • 333,147
  • 50
  • 533
  • 760