473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ


What is Perl?

By Blair Ireland
Senior Editor, TheScripts.com

What is Perl?

Perl was originally developed in 1986 by Larry Wall. Perl (Practical Extraction and Report Language) has become the language of choice for system and network administration, as well as for CGI programming. This is largely due to Perl being Open Source and its low cost (its FREE). It is the language of choice on the Internet.

In short, Perl is the prime scripting language. A scripting language is different then a regular programming language as the scripts require less code then a regular programming language to do the same thing. Scripts are also usually written in a regular text editor.

What does a Typical Perl Program Consist of?

A perl program consists of various elements. The following is a list of the typical elements found in a perl program;

"Shebang"

The "shebang" line is the first line of any perl program. It tells the OS (operating system) where to find the perl compiler so it can initiate it.

Example:

#!/usr/bin/perl

Required Libraries

Sometimes your program will require certain files or perl libraries or modules to run. This is where you define these external filesand make the program call them. Libraries and modules are relatively the same thing. These modules can come in extremely handy, and can prevent you from having to write a lot of code. You will notice that the example found below reference cgi-lib.pl. This is a popular cgi form parser used by a lot of programmers. It eliminates the need for them to create a form processor in their script and makes form parsing easy. There are many modules available for various functions, like making truly random numbers, or sending E-Mail with MIME encoding.02

Example:

require "cgi-lib.pl";

Global Variable Decarations

Any good, efficient programmer will always declare their important variables that run throughout the whole program here at the top of the script. This makes the script "cleaner" and easier to read.

The "Meat" of the Program

This is pretty much the most important part of a program. It is where you call all your subroutines to be used, and also is what makes the main decisions of what it is going to do. It controls the input and output of the program.

  Perl Subroutines »

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.