sub _process_attributes{ my $self = shift; my $child_tree = shift; my $attributes = shift || {}; my $attribute_values; foreach my $child (@$child_tree){ my $attribute_key = $child->{id}; my @attribute_array = split('-',$attribute_key); my $key; my $current_key; my $next_key; $attributes = hash_maker($attributes,@attribute_array); #2 MY PROBLEM IS HERE I WANT TO SET THE VALUES THAT MATCH THE KEYS BASED ON THE NEWLY BUILD HASH #if($child->{leaf}){ # #} if($child->{children}){ $self->_process_attributes($child->{children},$attributes) } } return $attributes; } sub hash_maker { my $ref = shift; my $key = shift; return undef unless ref $ref eq 'HASH'; # # If $key is empty, we're building an empty hash. Return undef. # return undef unless $key; # # This is the passed in hash, so we need to duplicate it in our new # data structure. We also have to be sure that we're adding if necessary. # if ( ref $key eq 'HASH' ) { my $hash; my $count = keys %$key; my $cnt = 1; foreach my $k ( keys %{$key} ) { $ref->{$k} = $key->{$k}; } return $ref; } # # Reference was not a hashref, we don't know how to handle it. # return undef if ref $key; # # Nothing above was met, there's more to build. # $ref->{$key} = {} unless exists $ref->{$key}; #shift(@_); hash_maker( $ref->{$key}, @_ ); # # Pass that which we hath groweth to those who groweth before us... # return $ref; }