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
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.