CGI-Perl

Overview
CGI is something that helps add interactiy or cool features to your site. CGI scripts have the extensions .cgi and .pl. There are a few different languages that allow you to create CGI scripts. (CGI is not a programming language). The main one is Perl. Perl CGI Scripts let you create search engine, mail forms, guestbooks, message forums, create statistics of your site's viers, and just about anything you want for your site. As you can see, Perl and CGI are some pretty powerfull things for the net.

Requirements

Perl scripts require that your server is equiped with perl. If you are unsure about this, contact your server administrator for help. You will have to find out a few things about your server before uploading any perl scripts. You should find out the system path of your site on the server, the location of perl, the location of the sendmail, and the location of the date command. Try looking at your server's support/faq page, or email your server administrator. Also, if your server doesn't support Perl, don't hesitate to go to the Get Hosted page and fill out the application to get hosted by me.

Editing Your Script

One of the best things in perl is the abbility to store information easily. There are a few ways of doing this, but we will only get into two of them. The two most commonly used methods are in scalars and arrays. Scalars are used for storing single data. An example of a scalar is shown below:
$youremail = '[email protected]';
An array can be used in storing multiple data. An example of an array is shown below:
@referers = ('warzone2000.com','208.161.8.40')


Moving around a perl script

There are only a few out of many things I'll explain in this section. One of them is how to print new lines in the html field. To do this, you must enter a \n in the perl script. Usually, it looks like this:
print "Hello\n";
wrather then:
print "hello";
The different between these two is that the first one will print out a new line in the html code when somebody looks at the source. It makes it look much neater.

Uploading Your Script

After editing all the variables in the script(s), save it, and exit. All Perl Scripts have to be uploaded in ASCII mode, not binary. Log in to your FTP account, and create a new folder on the server called cgi-bin, or whatever the name of the folder with CGI capabilities is. Upload the script into that folder. Now, here comes the hard part! Almost all Perl CGI script have to be chmoded for them to work. Chmodding is also known as Changing the File Permissions. This will allow/not allow your viewers to see or interact with a designated file(s) on your server. (Chmodding can also be used to protect a directory from being seen by chmodding it to a very low number). Most Perl CGI Scripts have to be chmodded to 755. To find out how to chmod files using your FTP, try reading the read me for it. For some FTP Programs, you can right click on the file you want to chmod, and look for something like "Change File Permissions" or "Chmod". Also, you can use telnet to chmod CGI scripts.

Using SSI in CGI
SSI is a very important part in CGI scripts. It allows you to call a cgi script from a remote directory and print them on a designated page. Wrather then having the url http://www.warzone2000.com/cgi-bin/board/board.cgi, I could make the url something like http://www.warzone2000.com/board.shtml. An important part in using SSI is renaming your .htm or .shtml file to .shtml or .shtm. Some servers do not require this, but most do. The code for doing this is shown below:
<!--exec cgi="/cgi-bin/cgiscript.cgi"-->
Replace that /cgi-bin/cgiscript.cgi with the location of the script. Say your script was in /cgi-bin/downloads/antileech.cgi. This would be the code for that:
<!--exec cgi="/cgi-bin/downloads/antileech.cgi"-->
To find out how to use SSI in other ways, go to the SSI Tutorial.

Resources

http://www.find-script.com/
http://cgi.resourceindex.com/
http://www.freeperlcode.com/

<--------------------|-------------------->
Hosted by www.Geocities.ws

1