Perl Programming Page 5 - Perl 101 (Part 2) - Of Variables And Operators |
In addition to the various arithmetic and string operators, Perl also comes with a bunch of comparison operators, whose sole raison d'etre is to evaluate expressions and determine if they are true or false. Here's a list - you should use these operators for numeric comparisons only. Assume $x=4 and $y=10
If, however, you're planning to compare string values, the two most commonly used operators are the equality and inequality operators, as listed below. Assume $x="abc", $y="xyz"
You can also the greater- and less-than operators for string comparison - however, keep in mind that Perl uses the ASCII values of the strings to be compared when deciding which one is greater. Assume $x="m", $y="M"
The reason for this - the ASCII value of "m" is greater than the ASCII value of "M". This article copyright Melonfire 2000. All rights reserved.
blog comments powered by Disqus |