Perl is the stable, cross platform language.
Perl is a open source software.
Perl works with HTML, XML, and other mark-up languages.
Perl supports both procedural and object-orientedprogramming
Perl and the web
Perl is the most popular web programming language due to its text
manipulation (or) processing capabilities.
Perl is called The Duct Tape of Internet.
Perl's CGI.pm module, part of Perl's standard distribution, makes
handling HTML forms simple.
Perl can be embedded into web servers to speed up processing by
as much as 2000%.
Perl's DBI package makes web-database integration easy.
Basics of Perl
Names of scalar variables begin with $ sign.
Compiler declares variables implicitly when it
All numeric operations are done in floating
Eg:-5/2 =2.5 in Perl
Scalar variable which has not been assigned a
value will has the value undef.
chomp-removes any terminating new line
character from its parameter.
length-Returns the length of the string.
lc-converts the parameter string to the
uc- converts the parameter string to the
join-returns the string constructed by
concatenating the strings together them.
Input and Output
Input and output can be thought of file input and
Files are referenced in programs through
internal filenames called File handles.
Perl has the loops same as any other languages
Arrays in Perl are different in 3-ways
Can have absent elements
They can store different types of data.
The array variables are preceded by @ sign.
The length of the array is specified by $#list+1.
Push and Pop deal with the right end of the arrays
Shift and Unshift deal with the left end of the arrays
Perl associative arrays are called Hashes.
Two differences between arrays and hashes
1. Arrays use numeric subscripts where as
hashes use string values for element
2. Elements in arrays are ordered by subscripts
whereas in hashes they are like set.
The function header is the reserved word sub.
A function can specify the return values in 2-ways either implicitly or
If there are no calls for the return statement with in the function then
the return value is the value of the last expression encountered.
Local variables are declared in the function using the reserved word
It has also another reserved word local for declaring local variables.
All the parameters are passed to a function are placed in @_.
Every function has its own version of @_.
Common Gateway Interface—
A programming interface between a web
server and the systems backend functions
- such as processing systems and
databases. Allows web servers to perform
data functions and interact with users.
(or) A protocol that is used between a
browser and software on the server is
Life cycle of CGI program
The CGI program takes the user input .
Takes the decision based on the input
what action is to be taken.
Does the action and responds to the user
by creating the response web page.
Steps for building the CGI Applications-
CGI programs often reside in a specific directory
on the server. Eg:- cgi-bin
The server should be configured so that it can
recognize the CGI and Perl programs.
When a server receives a request for a CGI
program it executes the CGI program and
returns the output to the browser.
Using the CGI a browser can run the programs
on the server indirectly.
Query String Format
Http requests made by the users through the
methods like GET and POST using FORMS
transmit the data associated with the request in
the form of character strings called Query String.
The elements of the form that has the name and
value are coded as a character strings
name=value and included in the Query String.
Eg- caramel=7 where caramel is name of the
element and 7 is the value .
The special characters are coded by % sign.
Perl programs access a particular module
with the use declaration.
use CGI “:standard”;
The functions of the CGI.pm module which
are used to create the required XHTML
tags are called SHORTCUTS.
Eg- print br; implies <br />;