quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif Introduction

PERL was developed by Larry Wall (author of the USENET newsreader rn). Wall developed PERL originally as a data reduction language (that is, a language that is capable of consuming large quantities of data in an efficient manner and performing some function(s) on it).

   

space.gif

PERL is an acronym for "Practical Extraction and Report Language." PERL is almost the perfect tool for system administrators since it allows the easy manipulation of files, process information, and many other items. PERL is also great for people who write cgi-bin scripts to process web forms because it has so many useful string manipulation functions.

   

space.gif

Since PERL's syntax resembles shell programs and C and it has the builtin functions of awk, sed, and grep, many people find it very easy to learn. One thing to always remember about PERL...."There's always more than one way to do it." Five PERL programmers may write a simple piece of code to perform and function and they may each take five different approaches to accomplish the task.

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Invoking the PERL

Before we get knee deep in PERL, let me first mention how to execute the upcoming examples. Create these files with your favorite text editor then type:

   

space.gif

% perl myprogram.pl

   

space.gif

Where myprogram.pl is the name of the file you entered the PERL commands into. (If you get an error saying that perl cannot be found then the location of perl is not in your path OR perl is not installed on your system - check with your system administrator.) The filename.pl is a handy convention for recognizing your perl scripts.

   

space.gif

Of course, you can use the technique that Unix shells use. The first line of your program can read:

   

space.gif

#!/usr/bin/perl

   

space.gif

Be sure that you replace /usr/bin with the appropriate path to your perl binary. Also, be sure that you can execute the script. If you type:

   

space.gif

% myprogram.pl

   

space.gif

and get an error similar to:

   

space.gif

csh: myprogram.pl: cannot execute

   

space.gif

Then you should probably type:

   

space.gif

% chmod +x myprogram.pl

   

space.gif

which will make the program executable.

   

space.gif

  ../images/main/bulllet_4dots_orange.gif PERL syntax
   

space.gif

PERL is a free-form language.

PERL doesn't care how you write code for the most part. That is, use as much whitespace as you want or as little as you want (with the exception of the format declaration and quoted strings)

   

space.gif

A PERL script is comprised of declarations and statements.

Your actual PERL code will normally be doing one of two things. Either you are declaring a subroutine (or a report) or you are giving PERL a statement of code. You don't have to declare variables that you will be using ahead of time since any uninitialized variables and arrays start with a null or 0 value until they receive a value of their own.

   

space.gif

Like C, PERL statements must end in a semicolon (;). Semicolons seperate statements so you can put many statements per line (free-form) but you might sarifice clarity

   

space.gif

* Comments begin with a pound sign (#).

PERL comments work like shell script comments. Anything after an unquoted # in a script is ignored. Comments can begin anywhere on a line.

   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com