Perl Beginners - Addressbook Tutorial Summary 1 - A summary of what we've accomplished so far

Table of Contents | Step 6 | Step 7

So what have we done?

Well, we've created 6 files, the cgi, an html template file, the base class, a perl handler, a utility class, and an sql class. When we point a browser to the cgi, it calls an action method the perl handler. The perl handler calls the utility class (if necessary) when it needs to work with the data in the database. The utility handler looks in the sql class if it needs to execute queries. After the perl handler finishes executing the action method called by the cgi, it loads the template variable hash, then sends the output to the html template file (which is consequently displayed in the browser). After that, clean-up is done by destroying the database handle.

Here is a diagram of our files:

The cgi constructs a CGI.pm object and a handler object. It then puts the form variables in an array and passes the array to the appropriate action method in the handler. Then, it calls the sendoutput method in the handler and exits. The constructor in the perl handler, Handler.pm, creates an object reference that holds a database handle, the action to take, a reference to a template variable hash, the template filename, and the cgi object. The constructor in the utility class, Record.pm, creates an object reference that holds the database handle created by the perl handler's constructor. The SQL.pm class doesn't need a constructor because it simply returns text queries to the utility class. The template file is seeded with TMPL_VAR and TMPL_LOOP tags to accept the reference to the data hash created by the handler.

We'll need to create only one other file, the restricted perl handler. In Step 1, we made the case that we'll need to somehow restrict the methods that add, edit, update, and delete entries in the database. The restricted perl handler will be similar in design to the regular perl handler. We'll create this class later.

Until then, any additional code we'll write will be methods in each of the classes we've already created.

Coming next - Creating methods to search and display results.


Copyright © 2001 by Peace Computer Systems