Next | February 2001 | Slide #7 |
use Person;
$hamlet = Person->new(); $hamlet->set_name('Hamlet'); $hamlet->set_age(24);
print $hamlet->get_name, "'s age is", $hamlet->get_age, "\n";
use Person loads the Person module
The module implements the Person class
Subroutines in Person are the methods for class Person
Person does not export anything
If $hamlet is a Person object, $hamlet->set_name will call Person::set_name
No need for exporting
No namespace collision problems
Next | ![]() |
Copyright © 2001 M-J. Dominus |