The first time I looked at a Perl program, my reaction was "that is some ugly code." I still think Perl is an ugly language, but it sure is useful! I am amazed at how quickly you can construct a useful application with Perl.

After reading this chapter, you may think that Perl is great for quick-and-dirty programs, but not for serious applications. I would disagree?like any programming language, you can write incomprehensible code in Perl. But you can also write Perl scripts that are easy to understand and not too difficult to maintain. Include comments in your code. Avoid constructs that are difficult to understand. Perl often offers many ways to do any one thing: Use the most descriptive form, not the most cryptic.

One of the real benefits to the combination of Perl and PostgreSQL is that you can execute Perl scripts (accessing a PostgreSQL database) from within a web server. When you write Perl scripts intended to run within a web server, the script produces a new web page each time it executes. Because a Perl script can interface with PostgreSQL, you can generate dynamic web content on-the-fly.

I haven't covered web interfacing in this chapter, but Chapter 15, "Using PostgreSQL with PHP," shows you how to use PostgreSQL with the PHP web server scripting language.

    Part II: Programming with PostgreSQL