Perl Tutorial : Perl data types
Perl Tutorial : Perl Operators
Perl Tutorial : Perl loops
Perl Tutorial : Perl Conditionals
Perl Tutorial : Perl Subroutines
Perl Tutorial : Perl regex
Perl Tutorial : Perl Files
Perl Tutorial : Perl & Databases
Perl Tutorial : Perl OOPs
Perl Tutorial : Perl signals
Perl Tutorial : Perl threads
Perl Tutorial : Perl Debugging

Introcution to Perl CGI

Introduction to modperl
Home >> perloperators >>

Perl Operators

In Perl, the comparison operators are divided into two classes:
  • Comparison operators that work with numbers
  • Comparison operators that work with strings
Integer-Comparison Operators
Operator Description  
<        Less than
>        Greater than
==       Equal to
<=       Less than or equal to
>=       Greater than or equal to
!=       Not equal to
<=> Comparison returning 1, 0, or -1
Each of these operators yields one of two values:
  • True, or nonzero
  • False, or zero
The <=> operator is a special case. Unlike the other integer comparison operators, <=> returns one of three values:
  • 0, if the two values being compared are equal
  • 1, if the first value is greater
  • -1, if the second value is greater


String-Comparison Operators
For every numeric-comparison operator, Perl defines an equivalent string-comparison operator.
String operator Comparison operation 
lt              Less than
gt              Greater than
eq              Equal to
le              Less than or equal to
ge              Greater than or equal to
ne              Not equal to !=
cmp             Compare, returning 1, 0, or -1
Example
#!/usr/bin/perl
$a="perlhome.com";
$b="www.perlhome.com";
if($a eq $b)
{
print "Both are same";
}
else
{
print "Both are different";
}

Perl functions

scalars and strings

lc
ord

regex (regular expressions)

arrays

shift
split

More..

eval
Share |


Perl examples

  • How to use Data::Dumper?
  • How to parse config file?
  • Include external module in perl..
  • Download perl

    download stable version of perl
    Perl 5.10.1
    Perl interview Questions
    sed tutorial
    awk tutorial

    Join us on Google Groups

    Subscribe to perl
    Email:
    Visit this group
    Perl Jobs


    privacy | sitemap | disclaim | contact us
    © 2009 perlhome.com