- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Perl Equality Operators
These are also called relational operators in Perl. Assume variable $a holds 10 and variable $b holds 20 then, let's check the following numeric equality operators available in Perl −
Sr.No. | Operator & Description |
---|---|
1 | == (equal to) Checks if the value of two operands are equal or not, if yes then condition becomes true. Example− ($a == $b) is not true. |
2 | != (not equal to) Checks if the value of two operands are equal or not, if values are not equal then the condition becomes true. Example− ($a != $b) is true. |
3 | <=> Checks if the value of two operands are equal or not, and returns -1, 0, or 1 depending on whether the left argument is numerically less than, equal to, or greater than the right argument. Example− ($a <=> $b) returns -1. |
4 | > (greater than) Checks if the value of the left operand is greater than the value of right operand, if yes then condition becomes true. Example− ($a > $b) is not true. |
5 | < (less than) Checks if the value of the left operand is less than the value of right operand, if yes then condition becomes true. Example− ($a < $b) is true. |
6 | >= (greater than or equal to) Checks if the value of the left operand is greater than or equal to the value of right operand, if yes then condition becomes true. Example− ($a >= $b) is not true. |
7 | <= (less than or equal to) Checks if the value of the left operand is less than or equal to the value of right operand, if yes then condition becomes true. Example− ($a <= $b) is true. |
Below is a list of equity operators. Assume variable $a holds "abc" and variable $b holds "xyz" then, let's check the following string, equality operators −
Sr.No. | Operator & Description |
---|---|
1 | lt Returns true if the left argument is stringwise less than the right argument. Example−($a lt $b) is true. |
2 | gt Returns true if the left argument is stringwise greater than the right argument. Example−($a gt $b) is false. |
3 | le Returns true if the left argument is stringwise less than or equal to the right argument. Example− ($a le $b) is true. |
4 | ge Returns true if the left argument is stringwise greater than or equal to the right argument. Example−($a ge $b) is false. |
5 | eq Returns true if the left argument is stringwise equal to the right argument. Example−($a eq $b) is false. |
6 | ne Returns true if the left argument is stringwise not equal to the right argument. Example− ($a ne $b) is true. |
7 | cmp Returns -1, 0, or 1 depending on whether the left argument is stringwise less than, equal to, or greater than the right argument. Example−($a cmp $b) is -1. |
Advertisements