in reply to Re: Re: setting hash keys by array
in thread setting hash keys by array
They do this instead: $hash{red}{green}{brown} = { }True, that's what comes out of the for loop. Then the next instruction in my sample turns it into the requested result.. Is the following more to your liking?
or maybemy $ptr = \%hash; $ptr = $ptr->{$_} = {} for @array[0..$#array-1]; # fixed; s/shift @arr +ay/$_/ $ptr->{$array[-1]} = 1;
Update: forgot to remove the shift when I initially copypasted. See comment.my $ptr = \%hash; $ptr = $ptr->{shift @array} = {} while @array > 1; $ptr->{$array[0]} = 1;
Makeshifts last the longest.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re^3: setting hash keys by array
by blssu (Pilgrim) on Sep 09, 2002 at 21:03 UTC | |
by Aristotle (Chancellor) on Sep 10, 2002 at 08:57 UTC |