I have written this guide to help beginners learn to set up and use cgi scripts, particularly perl.
I am eminently qualified to do this, as I am a beginner myself, having started playing with cgi on 10 Aug 96.
What I found out in the painful, long-drawn-out process of setting up my perl scripts, was that the experienced "gurus" assume (making an ass out of u and me) that because they know something, everybody else will automatically know it too, which makes getting guidance like getting blood out of a stone.
To make it easier for you to tell explanations and instructions from example code etc, I have used the following colour (<color>) conventions:
| Black | Black - All the boring explanations and instructions |
| White | White - Examples of perl code |
| Yellow | Yellow - Examples from html forms |
| Lime | Lime - Your keyboard input - what I want you to type. |
| aqua | Aqua - Program Menu Items |
Important!! If you want to print this page, you need to change all the yellow and white to another colour (<color>) before printing it. To do this, go to File...Save As and save it somewhere, then edit it by doing a global search and replace - case sensitive (so the words White and Yellow in the table above don't change) - suggest color=white replace with color=navy , color=yellow replace with color=green , then save it and in your browser go to File...Open and open it, then print that one.
1.
Do I need to learn cgi and perl?
If all you want to do is get feedback from a web form such as Add Yourself to The Fogies Photo Gallery or Julie and Jay's Tarot on the Net Survey, you can use a mailform script located on someone else's site.
If you examine either of those forms (by following the links and then selecting View...Document Source) you will find a line like this:
<FORM method=POST ACTION="http://www.iinet.net.au/cgi-bin/cgi/jaguar/mailform.pl">
OR
<form action="http://www.iinet.net.au/cgi-bin/cgi/jaguar/mailtoda3.pl" method="POST">
Note that only one of these forms is located on my site, but both of them use one of my scripts which is located on my site. The Tarot on The Net Survey uses a special script I wrote so that Julie can copy from the email and paste directly into an Excel spreadsheet.
These scripts could as easily be used from any site in the world, so maybe you don't need to do the hard stuff.
2.
What Do I Want To Do?
If all you want is a simple feedback form, why go through the angst of getting into cgi & perl? - forms are very easy in comparison, and you will still need a form anyway.
If that is all you are after, Email Me with your Homepage URL and a description of what feedback you are after.
If you want a guestbook, and you are an iinet subscriber, you can also have a very nice guestbook without learning cgi and perl. If you are with another isp, and you can get CGI permission and the answer to a few simple questions, you can also get by without learning cgi and perl.
Take a look at any of these guestbooks to see what is available from me:
Commander Keen's Guestbook
Judy's Guestbook
Julie and Jay's Genealogy Guestbook
Rod's Guestbook
Tony's Guestbook
The Fogies Photo Gallery Guestbook
My Grandson Axcel's Guestbook
My Guestbook
If that is all you are after, and you are an iinet subscriber, Email Me with your Homepage URL.
If you are not an iinet subscriber, but you would still like a Guestbook like mine, Email Me with your Homepage URL, and the answers to questions 1 to 5 below. Make sure your isp will give you CGI permission first though.
3.
So - Do You Still Want To Go Ahead?
Now that we've got that out of the way, let's get serious about how we are going to do this. First off, there are a couple of things you need to know about your server:
$database = "//u/j/jaguar/public_html/database.txt"; Note that there is no ~ (tilde) in the PATH.
or (in some of my scripts) like this:
$userpublicreal = "//u/j/jaguar/public_html/";
$guestbookfile = "guestbookkeith.html";
$guestlogfile = "guestlogkeith.html";
$database = "database.txt";
These will be put together later in a script with lines like these:
$guestbookreal = $userpublicreal$guestbookfile;
$guestlog = $userpublicreal$guestlogfile;
Because I write some of my scripts, particularly my Guestbook script, to be used universally within a domain, often the Form which calls the script will have details of the file path, in this form:
<INPUT TYPE="hidden" name="userpublicreal" value="//u/j/gaynor/public_html/">
<INPUT TYPE="hidden" name="guestbookfile" value="guestbookrod.html">
<INPUT TYPE="hidden" name="guestlogfile" value="guestlogrod.html">
These are put together later in the script with lines like these:
if ( $FORM{'userpublicreal'} && $FORM{'guestlogfile'}){
$guestbookreal = "$FORM{'userpublicreal'}$FORM{'guestbookfile'}";
$guestlog = "$FORM{'userpublicreal'}$FORM{'guestlogfile'}";
}
else {
die "Guestbookreal or filename or logfile not specified in form \n";
}
The same form also passes the URL of the user's homepage with this line: Note the ~ (tilde) in the URL.
<INPUT TYPE="hidden" name="userpublicurl" value="http://www.iinet.net.au/~gaynor/">
This is then used to find the URL of the guestbook with these lines:
if ( $FORM{'guestbookfile'} && $FORM{'userpublicurl'}){
$guestbookurl = "$FORM{'userpublicurl'}$FORM{'guestbookfile'}";
}
else {
die "Guestbook url or filename not specified in form \n";
}
If this all looks a bit confusing, please bear with me, I will explain all the weird looking stuff when we get down to the nitty gritty.
Here is my step by step guide to getting started.
CHOOSING A SCRIPT
The easiest way to do anything with scripts is to use one that someone else has written and tested. The best source I've found is Matt Wright's Script Archive, but there are plenty of others around. A search with Webcrawler for "perl script download" WITHOUT the quotes should find plenty. Another excellent source is Excite's Perl Page. A search with Excite for "perl script download" WITH the quotes should also find plenty, including a link to their perl page at the start of the list which says "Try these first: Web sites about Perl".
Personally I find Matt's Script Archive is the most comprehensive collection of useful scripts, with excellent Read Me files and clear internal documentation. That is the reason that most of my forms have something like the following at the bottom:
![]() | Script modified by Keith Lewis from an original script Created by Matt Wright which can be found at |
![]() |
If anything doesn't load properly or you have any suggestions for improving this page, please feel free to email me at jaguar@iinet.net.au.