Perl Tutorials - Herong's Tutorial Examples - Version 5.31, by Dr. Herong Yang
Basic Concepts of Classes and Objects
This section describes what is a class and what is an object. Perl uses packages to simulate classes and references to simulate objects.
Class - A user defined complex data type with attributes and operations.
Object - A data instance of the data type defined by a class.
Class variable - An attribute that is shared by all objects of a class. A class variable is also called a static variable.
Object variable - An attribute that is associated with each individual object of a class. An object variable is also called an instance variable.
Class method - An operation that requires a class to be implicitly associated with. A class method is also called static method.
Object method - An operation that requires an object to be implicitly associated with. An object method is also called an instance method.
In order to use classes and objects, other languages have special syntaxes to define classes, declare objects, access attributes, and invoke operations. But Perl tries to extend the package concept to simulate class and extend the reference concept to simulate object.
Table of Contents