3. What is CGI
Protocol for executing scripts via web requests
Rules and standards that define how the information is exchanged between
the web server and custom scripts
Code called by HTTP server was referred to as the CGI script
CGI applications are very powerful (accessing database, generate graphics,
hold telnet session )
Protocol for generating dynamic web pages
4. CGI (Common Gateway Interface)
Common
Interaction with many OS.
Gateway
Provides way to gain access to different programs such as database
Interface
A method for interaction with web server
5. CGI Architecture
HTTP protocol initiate connection on client machine
Client machine exchanges information with web server
Web server run server side script to access the dynamic content
6. Perl
Perl is a programming language developed by Larry Wall
Stands for Practical Extraction and Report Language
Platform Independent
Perl 1.0 was released in 1987
Latest Perl version is 5.30.1
Works with HTML, XHTML
Perl database integration interface support third party databases
7. Basic Syntax
Variables
Variables are user defined words used to hold values
Examples:
$name = “Visit Nepal” ;
$num = 10 ;
@ages = ( 10, 21, 56, 20, 92) ;
Expression
Made up of variables and operators symbols
Example:
$x + $y
8. Basic Syntax
Comments
Useful information developer provide to understand source code
Types
Single line comments
Start with hashtag symbol i.e. #
11. Datatypes in Perl
Arrays
Variable that stores values of same data types
To declare array in perl, we use @ symbol
Example
@number = ( 40, 55, 63, 17, 22, 68, 89, 97, 89)
To access single element in array, we use $ sign as :
$number[0]
12. Datatypes in Perl
Scalars
Single unit of data which can be integer number, float, a character, a string
Example
13. Datatypes in Perl
Hashes (Associative Arrays)
Set of key-values pairs
To declare Hash in Perl, we use ‘ % ’ sign
To access particular value, we use ‘ $ ’ symbol which is followed by key in braces
Example
14. Datatypes in Perl
Strings
Strings starts with $ sign and it can contain alphabets, numbers, special character
Can contains single word, a group of words , paragraph
Single or double quotes can be used
Example
15. Hello World Program in Perl
In Perl, basic program consists of the following steps of execution
Step 1 : Transfer the file to Perl Interpreter
Step 2 : Modules in Perl
Step 3 : Use of print() of function