Logical Operators in Perl

What are the Logical Operators?


The following are the Logical Operators used in Perl.
Operator Function
&& and logical conjunction of the two surrounding expressions
|| or logical disjunction of the two surrounding expressions
! not returns the logical negation of the expression to its right

Example :

#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
if( ($a<$b)&&($b>$a))
print "Condition is true";
print "Condition is False";
Result :

Condition is true

In the above example, the variables are compared with two conditions 1<5 and 5>1, so the result would give "Condition is True" as both the conditions are satisfied.

Ask Questions

Ask Question