Create a multidimesional key of hash from array?
问题 I want to create a multidimensional %hash from the @array . Suppose @array is like my @array=(1,2,3,4,5); I want to assign @array last value as final value to multidimensional %hash i.e %hash=( 1=>{ 2=> { 3=> { 4=>5 } } } ) Which means $hash{1}{2}{3}{4}=5; I want to do it in something like: for my $i (0..$#array){ #push $i as key until second last element and assign last element as value } Note : The @array may be of any size, Just I want to assign last element of @array as value to the keys