Perl Fundamentals
Posted August 21, 2008 at 10:46 pm in Programming | No CommentsPerl started out as the “Swiss army knife” of computer languages and was used primarily by system administrators, but over time it’s grown into an immensely robust language used by web-developers and programmers worldwide.
The Comprehensive Perl Archive Network is a great resource for already developed Perl modules. More than likely someone has created a module to perform the task you’re trying to accomplish.
Perl programs should start with the following line of code:
#!/usr/bin/perl
This line of code passes the rest of the code to the Perl interpreter, which is located at /usr/bin/perl (depends on your configuration).
A Perl comment uses #.
Arithmetic operators in order of precedence: EXPONENT **, (Unary Minus), MULTIPLY *, DIVISION /, ADD +, and SUBTRACT -. The MODULO % operator has the same precedence as * and /.
Bitwise operators are: AND &, OR |, XOR ^, and NOT ~.
Comparison operators: EQUAL TO ==, NOT EQUAL TO !=, LESS THAN <, GREATER THAN >, LESS THAN OR EQUAL TO <=, and GREATER THAN OR EQUAL TO >=.
Balance operator: <==>. This operator will point to the smaller number by indicating a 1 if the smaller number is on the right, -1 if the smaller number is on the left, or 0 if they are equal. Think of it like a number line as the arrows represent numbers increasing and decreasing to infinity and the equal signs representing the line, < -1 = 0 = 1 >.
Boolean operators: AND &&, OR ||, and NOT !.