Let's look at the less than comparison operators. Using this first operator, you can test to see if one value is less than another value. To see if two numeric values are less than each other, we use the comparison operator <. To see if two string values are less than each other, we use the comparison operator lt (Less Than).
if (4 < 5) { print "< for numeric values\n"; }You can also test for, less than or equal to, which looks very similar. Remember that this test will return true if the values tested are equal to each other, or if the value on the left is less than the value on the right. To see if two numeric values are less than or equal to each other, we use the comparison operator <=. To see if two string values are less than or equal to each other, we use the comparison operator le (Less-than Equal-to).
if ('A' lt 'B') { print "lt (Less Than) for string values\n"; }
if (5 <= 5) { print "<= for numeric values\n"; }Remember that when we talk about string values being less than each other, we're referring to their ascii values. So the capital letters are technically less than the lowercase letters, and the higher the letter is in the alphabet, the higher the ascii value. Make sure you check your ascii values if you're trying to make logical decisions based on strings.
if ('A' le 'B') { print "le (Less-than Equal-to) for string values\n"; }
Previous: Comparison Operators - Greater Than, Greater Than or Equal To

