O'Reilly logo

Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP by Brent Ware, James Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.3. A First CGI Program

CGI using Perl is straightforward. If you can write a Perl program to print “hello, world!” you’re halfway there. So, to be consistent with previous first examples (and because we haven’t chanted the mantra in a while), let’s start with “hello, world!”. Change to the proper directory that contains the server’s CGI programs:

$ cd /var/www/cgi-bin
					

Create the file hello.cgi, which contains the following text: [2]

[2] The file extension is a matter of style (or lack thereof); we use .cgi for the CGI programs in this book. Another logical option might be the .pl extension, because the program is Perl, but we’ll maintain a somewhat artificial distinction between plain-Jane Perl scripts and CGI web scripts.

 #!/usr/bin/perl ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required