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 | Basic Syntax of a Perl Program
- Perl Tutorial - Learn Perl With Examples
- Perl | lt operator
- Perl | qw Operator
- Perl matching operator
- Perl | qq operator
- Perl | print operator
- Perl | redo operator
- Perl | q operator
- Perl | substitution Operator
- Perl | next operator
- Perl | gt operator
- Perl | le operator
- Perl | ge operator
- Perl | eq operator
- Perl | ne operator
- Perl | y Operator
- Perl | tr Operator
- Perl | split() Function
- Perl | chomp() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.