- Perl Basics
- Perl Home
- Perl Basic Syntax
- Perl Data Types
- Perl Variables
- Perl Scalars
- Perl Arrays
- Perl Hashes
- Perl If-Else
- Perl Loops
- Perl Operators
- Perl References
- Perl Subroutines
- Perl Formats
- Perl Date & Time
- Perl File I/O
- Perl Advanced
- Perl Directory
- Perl Regular Expressions
- Perl Special Variables
- Perl Socket Programming
- Perl Send E-mail
- Perl Object Oriented
- Perl Error Handling
- Perl CGI Programming
- Perl Database
- Perl Packages & Modules
- Perl Process Management
- Perl Test
- Perl Online Test
- Give Online Test
- All Test List
Perl CGI Programming
CGI stands for Common Gateway Interface, is basically a set of standards that defines how the information is exchanged between the web server and the custom script.
Before proceeding with CGI programming in perl, first make sure that your web server supports the CGI functionality and it is configured to handle any CGI programs correctly. All the CGI programs to be executed by the web server are basically kept inside a pre-configured directory, called as CGI directory and by convention it is named as /cgi-bin. You .cgi extension to all the perl CGI files.
My First CGI Program in Perl
Here is a simple CGI program in perl, give you some basic idea about CGI programming in perl. This is hello.cgi file, kept in /cgi-bin/ directory.
#!/usr/bin/perl print "Content-type:text/html\r\n\r\n"; print '<html>'; print '<head>'; print '<title>My First CGI Program in PERL</title>'; print '</head>'; print '<body>'; print '<h2>Hello World, This is my first CGI program in PERL</h2>'; print '</body>'; print '</html>'; 1;
Now if you click on the link, hello.cgi, here is the sample output produced:
Hello World, This is my first CGI program in PERL
« Previous Tutorial Next Tutorial »