introduction to web programming Perl Objects To instantiate an object from a class, you need only call the class' "new" method such as:

     $new_object = new ClassName;

For example,

     $new_cat = new Cat("Fred", "white");

When you do so, the new() subroutine in that Cat class will be called. As you recall, the new() subroutine created a reference to an anonymous hash, blessed the reference, and returned it. Thus, $new_cat will store the pointer to your cat object.

So once you have instantiated an actual cat object, you will need to know how to do things with it. How can I make Fred say "meow"?

Previous | Next | Table of Contents