only for RuBoard - do not distribute or recompile Previous Section Next Section

Chapter 9. Perl

The Perl programming language has grown from a scruffy tool exploited by Unix systems administrators for informal scripting to the most widely used development platform for the World Wide Web. Perl was not designed for the Web or for databases, but its ease of use and powerful text-handling abilities have made it a natural for application development in these areas. A few of the libraries developed for Perl—called modules—have made it even more attractive for web and database applications.

Perl accesses databases through the DataBase Driver/DataBase Interface (DBD/DBI). The name arises from its two-layer implementation. At the bottom is the database driver layer. There, modules exist for each type of database accessible from Perl: MySQL, Oracle, and so on. On top of these database-dependent driver modules lies a database-independent interface layer, which is the interface you use.

The advantage of this scheme is that the programmer has to learn only one API: the database interface layer. Every time a new database comes along, someone needs only to write a DBD module for it, and it will be accessible to all DBD/DBI programmers. If you change databases, you can run your Perl program on the new database after changing only a couple lines of code.

This chapter is in three parts:

  1. An introduction to DBI, which shows you the basic statements you need to manipulate MySQL from Perl.

  2. A Common Gateway Interface (CGI) program that displays information from the database.

  3. For readers of stout heart, already comfortable with Perl, a general model that can be applied to a wide range of applications and that makes maintenance easier.

only for RuBoard - do not distribute or recompile Previous Section Next Section