All you need to do is
(a) store the array of obj3's as an array reference.
(b) dereference to access them.
Sample code : in obj2_maker method:
my @obj3s;
while (CONDITION) {
push @obj3s, Object3->new();
}
my $obj2 = Object2->new(-children=>\@obj3s); # edited ... had the drea
+ded "=" without the ">"
Note you'll have to write an appropriate constructor for Obj2.
In obj2's children method:
sub children {
my $self = shift;
@_ ? $self->{_children} = shift :
$self->{_children};
}
That method will return the anonymous array of children (if nothing is passed to it), or will
set the children of the object to the array that is passed to it.
Access the array by de-referencing.
@{ $obj2->children() }
This is a *very basic* framework. Don't take it as gospel. Just remember 'references' =)
HTH
perl -e 'print "How sweet does a rose smell? "; chomp $n = <STDIN>; $r
+ose = "smells sweet to degree $n"; *other_name = *rose; print "$other
+_name\n"'
|