cmp operator in Perl is a string equality comparison operator used to compare if the two strings placed left and right to this operator are equal or less than the other.
Syntax: string1 cmp string2
Returns: -1 if string1 is less, 0 if equal and 1 if greater than string2.
Example 1: When String1 is less than String2
Comparison of $a and $b returns -1
Example 2: When String1 is equal to String2
Comparison of $a and $b returns 0
Example 3: When String1 is greater than String2
Comparison of $a and $b returns 1
- Perl | tr Operator
- Perl | lt operator
- Perl | eq operator
- Perl | q operator
- Perl | le operator
- Perl | ge operator
- Perl | gt operator
- Perl | ne operator
- Perl | qw Operator
- Perl | next operator
- Perl | y Operator
- Perl | qq operator
- Perl | substitution Operator
- Perl | redo operator
- Perl matching operator
- Perl | print operator
- Perl Tutorial - Learn Perl With Examples
- Perl | Basic Syntax of a Perl Program
- Perl vs C/C++
- Perl | Modules
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.