| Previous | Next
Object-Oriented PerlIn Perl circles, modules and object-oriented developing are often spoken of in the same breath, but the connection is misleading. The implementation of modules in Perl is object-oriented, but that doesn't mean that the actual modules are objectified. Perl modules don't necessarily involve objects just because the Perl developer has encapsulated their code in a module. Generally, an object is an instance of a class. So in Perl terms, the object is created by calling a constructor, and will be used to create a new object and a reference to it. (Often, the constructor is named Methods are subroutines that expect an object reference as a first argument, such as:
Methods may be invoked like this: PackageName->constructor( or: $object = PackageName->constructor( Objects have a specific set of available methods within their class, but they also inherit methods from their parent class, if they have one. Objects are destroyed when the last reference to them goes away. You can control this capture before the object is destroyed with the |