Perl Beginners - Addressbook Tutorial Introduction |
Motivation |
I thought the inception of the beginners-cgi mailing list was a good idea. I have been programming Perl for 5 years now, and knew from experience the wrath that could be inflicted if a person posted to one of the comp.lang.perl.* newsgroups without carefully considering every word in their message. Even if someone posted a solution to a problem, chances were they'd get ripped up by other more experienced programmers on a 'better' or 'more elegant' way to do it. That kind of consequence can be a little intimidating to the newbie wanting to know why their script doesn't work. RTFM is a common answer to lots of newbie questions in the perl newsgroups. |
So, a mailing list where anything goes without fear of being flamed is a good thing, imho. After spending several days reading messages from people with code snippets asking for help, I realized how far I had come since writing my first perl script many years ago. And, I saw there were others struggling with the same problems I had when I first started. I decided to work on a complete tutorial to demonstrate how I develop a project from initial concept to production. What follows is my humble attempt to give back to the Perl community. |
Rules |
Well, let's call them guidelines instead of rules. Here are the guidelines I use when developing a project: |
Assumptions |
I will assume that readers of this tutorial will: |
Ok, maybe the last assumption is a bit too much. It means that if you are using a box owned by your ISP where you have access only to your own cgi-bin, you may have to put all of your modules and handlers in the cgi-bin. If you do this, be sure to limit access to the directories containing your Perl code or your modules may be served up as plain text by the Web server. Not a good thing. |
Modules |
All of my code use the following modules, which are available from CPAN: |
If you have never used these modules, or are unfamiliar with some of them, don't worry. As I go along with the tutorial, I'll give a basic explanation of how they work and why I use them. However, that should not stop you from getting them from CPAN, installing them, and reading the documentation. |
Server Configuration |
I run RedHat Linux/6.2, Apache/1.3.14, mod_perl/1.24_01, and PostgreSQL/7.0.3-2. Since MySQL is pretty prevalent in the Perl community, I'll try my best to point out the differences between PostgreSQL and MySQL and how to change any SQL so it will work with MySQL. For the most part, I'll avoid mod_perl, since not everyone runs Apache. |
Why I use HTML::Template |
Every place I've ever worked, the programming staff is divided into two groups: those who know how to program in Perl, and those who don't. Usually, the latter is tasked with developing the HTML and, in almost all cases, develop, tweak, or somehow change the HTML that is displayed to the user. Using HTML::Template provides a way for the HTML developer to massage the look-and-feel of the output without touching the code that generates it. All my code relies heavily on it, so if you're unfamiliar with HTML::Template, I'd suggest installing it and reading the documentation. You can do that by typing perldoc HTML::Template. |
Legalspeak |
Unfortunately, I have to include the following: |
Copyright © 2001 by Peace Computer Systems
|
Coming Next: Step 1 - Analyzing the project |
Copyright © 2001 by Peace Computer Systems |