Logical operators are defined : Boolean Operators « Language Basics « Perl






Logical operators are defined

    

$a || $b # logical or: true if either is nonzero 
$a && $b # logical and: true only if both are nonzero 
! $a # logical not: true if $a is zero 
Perl 5 also defines these logical operators: 
$a or $b # another form of logical or 
$a and $b # another form of logical and 
not $a # another form of logical not 
$a xor $b # logical xor: true if either $a or $b is nonzero, but not both 

   
    
    
    
  








Related examples in the same category

1.Logical Operators (Short-Circuit Operators)
2.! $v1 && $v2
3.&&, ||, and !
4.@a1 = $v1 && 1 .. 10;
5.Boolean Combination Operators
6.Compound Boolean operator Or: ||=
7.Precedence with word operators and short-circuit operators
8.Short-circuit operators
9.The 'and' Operator
10.Using boolean operator (and &&) to connect the comparison operator