in reply to Re: Hash to Hash to Hash ....
in thread Hash to Hash to Hash ....
the set function works if the 'a c b ' already exists. If it doesn't then we simply create a hash in space somewhere ( i think ). What I need is to dynamically create nodes which do no exist. I have done this by using a temporary hash to add the new item in and then link it back into the tree.set($ref_to_hash,1,(a c b d)) # set($hoh,$val, @path): ... by ariels sub set { my $hoh = shift; my $val = shift; my $last = pop @_; $hoh = $hoh->{$_} for (@_); $hoh->{$last} = $val }
Seems to work ok but I reckon you'll have a better way Thanks again wert#create first node $hr=\%I; $hr->{'one'}=1; #create tmp node and link back in $new=\%tmp; $new->{'two'}=1; $hr->{'one'}=$new;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: more Hash to Hash to Hash ....
by wertert (Sexton) on Aug 21, 2001 at 14:10 UTC |