Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Perl Logical Operators



There are following logical operators supported by Perl language. Assume variable $a holds true and variable $b holds false then −

Sr.No. Operator & Description
1 and
Called Logical AND operator. If both the operands are true then the condition becomes true.

Example− ($a and $b) is false.

 
2 &&
C-style Logical AND Operator copies a bit to the result if it exists in both operands
Example− ($a && $b) is false.
3 or
Called Logical OR Operator. If any of the two operands are non zero then condition becomes true.
Example− ($a or $b) is true.
4 ||
C-style Logical OR Operator copies a bit if it exists in either operand.p>
Example− ($a || $b) is true.
5 not
Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.
Example− not($a and $b) is true.

Quote-like Operators

There are following quote-like operators supported by Perl language. In the following table, a {} represents any pair of delimiters you choose.

Sr.No. Operator & Description
1 q{ }
Encloses a string with-in single quotes

Example− q{abcd} gives 'abcd'

 
2 qq{ }
Encloses a string with-in double quotes
Example− qq{abcd} gives "abcd"
       3 qx{ }
Encloses a string with-in invert quotes
Example− qx{abcd} gives `abcd`
Updated on: 2019-11-29T06:22:29+05:30

290 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements