Perl: More on Data Types and Operators - Comparing Numbers (
Page 5 of 5 )
|
Symbol |
What it Does |
|
== |
Equal to |
|
!= |
Not Equal to |
|
> |
Greater than |
|
< |
Less than |
|
>= |
Greater than or Equal to |
|
<= |
Less than or Equal to |
Comparing numbers is similar to comparing strings, except it is more obvious. 1 is greater than 2, 1 is equal to 1, 0 is less than 50, etc. I know, it's complex, fourth grade math and whatnot.
$value_one = 3;
$value_two = 2;
if ($value_one gt $value_two)
{
print “3 is greater than 2!”;
}
Logical Operators
-
|
Symbol |
What it Does |
|
&& |
AND |
|
|| |
OR |
|
! |
NOT |
Lastly, we come to the logical operators. These help set criteria for us to evaluate data with. We may want to write a program that asks if this value is greater than that value AND it is less than that value, do this. These are known as conditionals and we will discuss those in depth in the next tutorial.
That's it for this tutorial. In our next tutorial we will be dealing with Conditionals and Loops, so be sure to drop by and check it out or else I will be jobless and living on the street. I'll be that guy that asks for a dollar and then complains when all you give me is a dollar. How can I buy a bottle of rum for a dollar you cheapskate?
Till then...