Escolar Documentos
Profissional Documentos
Cultura Documentos
INTRODUCTION TO CGI:-
The common gateway Interface(C.G.I) is a specification defined by the world wide web
consortium, definining how a program interacts with a Hyper Text Transfer Protocal(HTTP)
server. The CGI provides middleware between www servers and external databases and
information sources.
WHY IS CGI USED:-
The interactive web pages, thet display some present information. These interactive web
pages enable a client to send information to the web server and get back a response that depends
on the input.
To create an interactive web page, HTML elements are used to display a form that
accepts a client's input and passes this to special computer programs on the web server. These
computer programs process a client's input and return requested information. These programs
are known as gateways because they typically act as a conduit between the web server and an
external source of information such as database.
PROCESS OF CGI:-
==>A client makes an HTTP request by means of a URL. This URL could be
typed into the 'location' window of a browser.
==>From the URL, the web server determines that it should active the gateway
program listed in the URL.
==>The gateway program process the information and returns HTML text to
the web server. Then it returns HTML text to web browser.
==>The web browser displays the document received from the web server.
POST=>>The web browser sends the form's data separately from the URL as a
stream of bits. In the POST method, the web browser sends the POST command to
the server and includes the form's data in the body of that command. The POST
method can handle any amount of data.
PERL
HISTORY OF PERL
Developed by "Larry Wall" basically on UNIX systems. The basic reason for developing
PERL is it gives much flexibility in string manipulations. PERL is an acronym for "Practical
Extraction and Reporting Language". It was originally created to extract information from text
files and then use that information to prepare breports.
Perl has gained recent attention in the explosion of the W.W.W as a quick and effective
way to mock up applications that provide much of the web's interactivity. It has a lot of syntax
that can make scripts contain more characters from the top row or the keyboard then any other,
but that is not necessary to get anything done. In fact there are few of the traditional limitations
that interpreted language impose.
FEATURES OF PERL:--
STRATEGY:-
Strategy for this seminar is to establish the basics of perl. The script we'll be useful to
anyone who has wanted to create some interactive pages on the world wide web. Web servers
usually support running auxiliary programs to facilitate interactive content.There is standard
called C.G.I which defines a minimum set of environment variables that the program can use to
determine its response.
The program we write will take the results of an HTML form and mail the values to a
specified person. Writing the HTML for this form is beyond the scope of this seninar, but a
sample form be provided.
The beauty of this program is that any user on the web server can use it to response to their
forms. You don't need to give everyone access to your server configuration. Users will enbable
themselves for this program, and then can write arbitrary forms from anyone on the web to fill
out.
VARIABLES:-
Variables are used to store data. In PERL each variable has a name and can store any
type of data. Each variable name in PERL begins with special character. There are five special
characters are used in PERL.
* a dollar($) sign
* an at(@) sign
* a percent(%) sign
* a amphercent(&) sign
* a lessthan greaterthan(<>) symbol
Special character denotes the variable type. There are five types of variables availible in
PERL language.
* Scalar variables
* Indexed Array variables
* Associative Aray variables
* subroutine
* file handler
In PERL, there is no data type for a variable. The sex or datatypr of the variable is
dependent on the context in which it is used.
SCALAR VARIABLES:-
A scalar variable can reference a string value or a numeric. We can identify these two by
visible difference. If the value of the variable is surrounded in single of double quotes, then PERL
treats the variable as a string. If there are no quotes, then PERL has to decide if the value is a
string or a numeric value. These variables are preceded by the '$' sign.
$firstname="sanjay";
$lastname="kumar";
$age=23;
These arrays are indexed by only integer values. Indexed arrays are denoted by the '@'
sign.
Ex:-@months=("jan","feb","mar","apr","may","jun");
Arrays are start at index 0. In the above example @months[0] will have a value jan and
@months[1] have feb.
Extracting Information from an Indexed Array:-
The 'qw' keyword is a ahortened form used to extract individual words from a string. The
most common method of extracting information from an array is to index the array elements
directly.
Ex:-@months=qw(jan feb mar apr may jun);
for($x=0;$x<=$#months;$x++)
{
print "index[$x]=$months[$x] \n";
}
These arrays are also called 'Hash' arrays. They are indexed by string values instead of by
integer index values. These arrays are identified by '%' sign.
Ex:-%cities=("a","hyderabad","b","bangalore","c","chennai");
The above example can be rewritten as:-
$cities{'a'}=hyderabad;
$cities{'b'}=bangalore;
$cities{'c'}=chennai;
ARITHMATIC&RELATIONAL OPERATORS:-
* Chop() - chop cutoff's or removes the last character in the scalar variable.
Ex:-#!g:\perl\bin\perl
$line="I LIKE YOU";
chop($line);
print"$line";
out put is I LIKE YO.
* Concatenation-The string concatenation operator is represented by a
period(".").
Ex:-#!g:\perl\bin\perl
$firstname="sanjay";
$lastname="kumar";
$fullname=$firstname . $lastname;
print "$fullname";
output is-sanjaykumar
* Chomp() - Removes the new line character if it presents in the string.
* <argv> - used to accept arguments through command line.
* shift() - Removes the first element from the array
Ex:-#!g:\perl\bin\perl
@cities=qw(H B C);
$delcity=shift(@cities);
print "@cities";
output is-("B","C")
DELETE
splice(@x,0,1) ---- Removes the first value.
splice(@x,1,3) ---- Removes 3 elements starting from second position.
splice(@x,$#x/2,2) ---- Removes 2 elements from the middle position.
INSERT
$p="Hello World";
splice(@x,0,0,$p) Now @=(,"Hello World",10, "svccs", 4, "mca");
REPLACE
$val=100;
splice(@x,2,1,$val) Now @=(,"Hello World",100, "svccs", 4, "mca");
FILE HANDLERS:
In each and every language input and output both from standard devices and from
diskfiles is important.
Perl sends data to output devices and receives data from i/p devices via i/o channels. The
i/o channels are called filehandles. File input from the keyboard and output to the printer, perl
provides two filehandles they are STDIN,STDOUT respectively. There is also a prenamed
filehandle for I/O errors, STDERR.
CONCLUSION
Perl basically evolved for extraction and report generation operations. Due to its
powerfulness it is widely used in string manipulations I/O and system tasks. Now perl is widely
used for writing C.G.I scripts.
BIBLIOGRAPHY
1.IVAN BAYROSS
2.perl from ground up--MICHAEL McMILLAN
3.URL:WWW.PERL.COM