Introduction to Objects

In traditional (functional) programming, variables and functions are distinct. With object-oriented programming, variables and functions are grouped together in objects. An object contains data and that data has behavior (functions) associated with it that specify in what way the data can change.

Why use objects?

Using objects reduces the complexity of a program by seperating it into smaller components of data and behavior. It also offers the potential of code reuse by using a existing data and behavior grouping (ojbect) in different contexts without having to reimplement the code for it. Object-oriented programming is a complicted subject. For more information see the Perl Object-Oriented Tutorial.



Features of Perl's Objects

For those familiar with object-oriented programming, Perl supports these object-oriented features:


Indirectly supported are:

Not support in Perl are:





Package mechanism/file forms the basis of the class.
Objects are references "blessed" into a particular class