Home arrow Perl Programming arrow Page 5 - Perl: More on Data Types and Operators

Comparing Numbers - Perl

So, when we last left off, I left you lost in a tumultuous sea of data types, variables, and strings. Fortunately for you, you have the black Perl, the world's fastest ship and a magical compass to point you in the right direction. So let's prepare to sail, er, study, and mind the shoals.

  1. Perl: More on Data Types and Operators
  2. Hashes are Yummy
  3. Operating the Deep Seas
  4. Incremental/ Decremental
  5. Comparing Numbers
By: James Payne
Rating: starstarstarstarstar / 2
October 15, 2007

print this article





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



What it Does







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

>>> More Perl Programming Articles          >>> More By James Payne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates


Dev Shed Tutorial Topics: