Free Perl Tutorials

Perl Packages, Perl Classes, Perl Objects....OH MY!

When I first started to learn PERL, one of my disadvantages was that I didn't even know the difference between a PERL package, a PERL class, and a PERL object. So what are they??

Think of a perl object as a way of storing a complex set of behaviors into a nice neat little bundle. A perl object resides within a perl class. And likewise, a perl package is made up of little individual perl classes. Therefore, an object resides within a class which belongs to a particular package! Easy? Good! Lets continue.

As you begin writing code, you will call on classes or objects within your programming to perform certain functions for you. If you request an entire class to do something for you, we say that you are calling a "class method". If you request an object to do something for you, we say that you are calling an "object method". When you request a class or object to return an object to you, you are calling on a constructor, which is an example of a type of method!