# object1: sub depth{ my $self = shift; my $max = 0; foreach my $item (0 .. 15){ if(defined($self->{child}->[$item])){ my $temp = $self->{child}->[$item]->depth; if($temp > $max){ $max = $temp; } } } $self->{myDepth} = $max+1; return $max+1; } # object2 sub depth{1}