5.6.1 Deciding How an Object Instance is Stored

5.6.1  Deciding How an Object Instance is Stored

 

Before writing an object-oriented program in Perl, we must first decide how individual object instances are implemented. We can have any implementation we want, but most commonly an object instance is implemented in terms of an anonymous hash as we have done in the program given above. Some programmers may use anonymous arrays for implementing object instances.

In the program, the components of the hash used to define an object instance are assigned values by making calls to methods. The two classes we have defined, Person and Friend, each has a set of methods to assign values to and access values of components of the anonymous hashes that implement object instances.