VOOZH about

URL: https://www.geeksforgeeks.org/computer-science-fundamentals/perl-boolean-values/

⇱ Perl | Boolean Values - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Perl | Boolean Values

Last Updated : 21 Aug, 2021

In most of the programming language True and False are considered as the boolean values. But Perl does not provide the type boolean for True and False. In general, a programmer can use the term "boolean" when a function returns either True or False. Like conditional statements(if, while, etc.) will return either true or false for the scalar values.

Example:

Output: 

k is False
m is True


True Values: Any non-zero number i.e. except zero are True values in the Perl language. String constants like 'true', 'false', ' '(string having space as the character), '00'(2 or more 0 characters) and "0\n"(a zero followed by a newline character in string) etc. also consider true values in Perl.

  • Example: 

Output: 

a is True
b is True
c is True
d is True


False Values: Empty string or string contains single digit 0 or undef value and zero are considered as the false values in perl.

  • Example: 

Output: 

a is False
b is False
c is False
d is False


Note: For the conditional check where the user has to compare two different variables, if they are not equal it returns False otherwise True.

  • Example: 

Output: 

Return True


 

Comment
Article Tags: