There's no point in beating around the proverbial bush. We dive right into
the code in this assortment of case studies. They are also mixed with sections
called "Perl Basics" so that you won't totally get cross-eyed learning everything
you need to now to make the most fantastic website on earth...well, at least
you'll have the interactive Perl part down :)
What you need to follow along with these:
-
patience
-
It is a virtue - but seriously, you'll need patience in order to program
in Perl generally due to the ambiguous nature of debugging Perl scripts
-
a text-editing program
-
If you've been following along with
MS Notepad,
EditPad or such, you'll
need it here now. (I prefer MS Wordpad when writing really long Perl scripts,
but who's keeping track anyway?). If you're developing right on the server
(UNIX) consider vi, emacs or pico - anything that works for you.You need
to be able to save the file with a .cgi extension.
-
a cgi-bin
-
Yes, this is actually the most essential part! But if you don't have access,
don't skip this section in frustration, you can get a free web space account
with a free cgi-bin! Check out our list of such service providers
here.
Simple CGI
See what a basic CGI script looks like. This is an introduction to simple
output in a perl script. The case study goes into greater detail with quotes
and EOF markers and how metacharacters and escape sequences modify the output.
Perl Basics: Becoming a Perl Newbie Extraordinare
You will find within some very important concepts in Perl. Know your variables,
arrays, hashes and subroutines. The rest of these tutorials will test your
knowledge of how these work. Included in each tutorial is an attempt to explain
how these interact and pass data in the script. If you don't know about these
concepts yet, this is a must-read.
Counter CGI
Not really a robust counter for your website, but it is a good introduction to and an application of some arithmetic processes built into Perl.
Form CGI
You may have gotten a taste of how forms send data in our HTML Forms tutorial,
but now you get to see how the other side accepts and parses (turns it into
something readable and usable) the form data.
Time CGI
How do you get Perl to tell you what time it is? No javascript required.
All you have to do is find out about some Perl functions like localtime()
and gmtime() and you're on your way.
Perl Basics: Reading, Writing and Taking a Bite
Another essential piece of reference. To increase the interactiving and ability
of the script to "remember" things, we'll need to store some information
in separate files. This tutorial shows you how Perl allows you to create,
edit and delete files. Some additional, and useful, information on parsing
your data is also included.
Guestbook CGI
A very simple application of reading and writing data to a HTML file to generate
a "guestbook" CGI script. SSI is not required (!) because, as you will see,
pattern-matching is used instead as a condition statement.
Redirect CGI
Get rid of the JavaScript redirection; this script will redirect using HTTP
headers. Learn how to tell your script to jump to another URL or page depending
on some variable data..
Poll CGI
Keep an informative one-question questionnaire on your site. It adds simple
interactivity on your website and the script itself can be quite a learning
experience while coding it. This is a very good example of the interaction
between separate files and the script.
Password CGI
Perhaps you want to manage a private forum or have a section for members
of your group/site account holders; Learn how basic username/password
authentification works. I discuss storage of data, the basic validation process,
and simple encryption in this case study.
Mailing List CGI
Learn how to use sendmail and send messages to a list of people. It is a
very simple application of a mailing list, but well worth knowing how to
do. The routines can be applied to a number of other scripts - such as sending
subscription notices, notifying the webmaster of new guestbook entries, and
how basic form-to-email works.
Unlimited Subdomains CGI
Have you ever wondered how to get a simple virtual subdomain like
http://yourname.yoursite.com instead of
http://www.yoursite.com/yourname? I'll show you an easy way - that
is fast and free, if you have wildcard subdomain names enabled.
News Grabber CGI
Learn how to grab headlines and blurbs from your favorite news and information
websites. This case study shows you now to use a function that can grab the
HTML from another web server - all you need to do is parse.
Random Quote CGI
A simple application of a built-in randomizer function. The difficulty lies in giving the randomizer the feel of random-ness!
Forum CGI Part 1
You've mastered the guestbook. Now try applying this to create a basic message forum! It will look a lot like the "Ultimate BBS" message forum, but is much simpler. (Note: no threading algorithm is required in this script)
Common Mistakes
As the title says, this is a list of common mistakes that people make when writing Perl scripts and suggestions on how to fix them. Included are general help tips on how to debug - very important particularly for beginners at programming. This list is based on the author's personal experience and complaints found on newsgroups/message boards.
Common Server Errors and Messages
Find out what those server response codes like 401, 404, 500 mean! It can help you troubleshoot minor problems - knowing these are a must if you'll be working on programs that run on a server.
Free CGI-BINs
We list most of the webhosts who offer people free CGI/Perl development capability in this section. Care to test them out and then leave a rating for others to see?