.:: Welcome To My Personal Blog ::.

Saturday, March 5, 2011

Beginner's Guide To Travel With Perl - Part 6

Built-in Operators

Arithmetic Operator :

+ Addition
- Subtraction
* Multiplication
/ Division




Unary Operator :

++$a, $a++ Auto increment
--$a, $a-- Auto decrement

Numeric Comparison :

== Equality
!= Inequality
<> Greater Than
<= Less Than or Equal >= Greater Than or Equal

String Comparison :

eq Equality
ne Inequality
lt Less Than
gt Greater Than
le Less Than or Equal
ge Greater Than or Equal

N.B.: There are no special variable types in Perl. But Perl needs to know whether to sort numerically (where 99 is less than 100) or alphabetically (where 100 comes before 99).

Boolean Logic :

&& and
|| or
! not



Miscellaneous :

= Assignment
. String concatenation
x String multiplication**
.. Range operator

** Here multiplication operator is also called the repeat operator. Again, it's a separate operator (x) to keep it distinct from numeric multiplication.

Some examples to remove confusion:
$a = 123;
$b = 456;
print $a + $b; # prints 579
print $a . $b; # prints 123456

$a = 123;
$b = 3;
print $a * $b; # prints 369
print $a x $b; # prints 123123123

The following operators are also available in Perl
$a += 1; # same as $a = $a + 1
$a -= 1; # same as $a = $a - 1
$a .= "\n"; # same as $a = $a . "\n";


Help Links:

http://www.perl.com/pub/2000/10/begperl1.html
http://perldoc.perl.org/perlintro.html

http://www.perl.org/learn.html
http://learn.perl.org/books.html
http://learn.perl.org/tutorials/
http://www.perl.com/pub/2008/04/23/a-beginners-introduction-to-perl-510.html
http://docstore.mik.ua/orelly/perl2/prog/ch01_05.htm
http://www.tizag.com/perlT/perluserinput.php
http://www.tizag.com/perlT/perlchomp.php

http://perldoc.perl.org/functions/use.html
http://www.well.ox.ac.uk/~johnb/comp/perl/intro.html

http://www.sthomas.net/roberts-perl-tutorial.htm/ch22/use_strict_
http://docstore.mik.ua/orelly/perl/prog3/ch31_19.htm
http://debugger.perl.org/580/perldebtut.html
http://perldoc.perl.org/strict.html


. . . . . To be continued . . . . .

3 comments:

  1. Excellent tutorial for the beginners.

    Go ahead!!!!!!!!!!!!!!!!

    ReplyDelete
  2. The Resource is not enough for me...need more and more... (Array and Function and Matrix related topics should be better).

    ReplyDelete
  3. Everything here is for novice user of Perl. Array and function (subroutine) are also described here. For more detais you may use the help links or google it. It's ur task to improve urself. Thanks

    ReplyDelete

Popular Posts