
gevni
Novice
Dec 19, 2012, 9:50 PM
Post #1 of 12
(2880 views)
|
|
How to store unknown Array into Hash?
|
Can't Post
|
|
Hi i have some arrays, and i don't get how i can store them in hash based on key. I know that i can define hash like that: my %hash = ( humans => [ 'hamnet', 'shakespeare', 'robyn', ], faeries => [ 'oberon', 'titania', 'puck', ], ); But i don't get how i can store unknown array in hash.
for($i=0; $i <$data ; $i++){ some code ...... ...... ....... for($j=0;$j <= $#$data_2; $j++){ ............... ........... } push @new_array, $data; #I want to store this @new_array into hash based on $i as a key. I don't want to use the reference because for every iteration @new_array contain new array value. I want some thing like that my %join_array[$i] = @new_array; } output should be 0->{o,1,2,3} 1->{2,3,5} 2-> {5,7,8} some thing like that. Thanks
|