Chapter 5. Object-Oriented Perl
Perl is a procedural language by nature. Many of the early programs written in Perl that you occasionally stumble upon on the Internet attest to this. With the advent of Perl 5.0, syntax and semantics were added to Perl to facilitate its use as an object-oriented language. As with many other aspects of Perl, Perl's implementation of object orientation is not "strict," and is not an inherent attribute of the language. This in no way diminishes its use as an object-oriented language, though it may incur the scorn of some object-oriented language purists. This has been the topic of many heated debates. Just buy your Java programmer friends lunch, and everything will be OK!
Chapter 4 covered references and packages/modules, both of which are key to understanding how to work with object-oriented Perl. With packages, you can have reusable code within a file that has variables and subroutines that are pertinent to a given functionality, as well as their own namespace. The subroutines and variables are accessed by specifying the package name. You saw how you could set a reference to a subroutine. These two things combined, along with the magical Perl function
bless (which will be discussed in this chapter), essentially give you what you need for object-oriented programming in Perl!
This chapter gives an overview of object-oriented Perl. Much of the code you will write for
mod_perl database-driven web applications takes advantage of the benefits of object orientation ...