In article <8_********************@adelphia.com>, John Smith
<so*****@microsoft.com> wrote:
Can someone point me to an example of how to implement and access the kind
of object shown below?
Most of the examples if found are an object that contains one other object.
I need to create an object that contains a hash of sub-objects each
sub-object is made up of a number of different objects and an array of an
object type.
Object1 contains scalars
Object2 Contains scalars
Object3 contains scalars (OK that part is easy)
Object4 contains an Object1, an Object2, an array of Object3, and scalars
Object5 contains a hash of Object4 and scalars
Object6 contains a hash of Object5
In general I will get or set each element in each object individually.
The ability to enumerate the object3s in the Object6 and the ability to
Enumerate through the object4s an object5 are the only other complex
accesses I need.
Objects in Perl are implemented as a reference to an anonymous hash.
The keys to the hash are the names of the members, and the values of
the hash may be any scalar. This includes normal scalar values and
references. Thus, a member of your object may be a reference to an
array or a hash or it may be another object (reference to a hash) or a
method (reference to subroutine). So you can have any level of nesting
of objects-within-objects and arrays or hashes of other objects. You
enumerate over array and hash members as you would enumerate over any
array or hash given a reference to one of these.
See the following documentation built into your installation of perl:
'perldoc perlreftut' Perl references tutorial
'perldoc perldsc' Perl data structures cookbook
'perldoc perllol' Manipulating arrays of arrays in Perl
'perldoc perlboot' Beginner's object-oriented tutorial
FYI: this newsgroup is defunct; try comp.lang.perl.misc in the future.