Hello monks,
Working to finish up an assignment tonight and I have gotten stuck on trying to convert an HoH to an array. I am attempting to extract an @array from the following data structure:
$hash{$w1}{$w2} = { total_counts => $tot_counts, words => { $nw => $count, } }
Basically I want to import all the keys from HoH 'words' (possibly using several '$nw's as keys) into and @array $count times each. I will then use the array function 'rand()' to randomly retrieve and print the content of one of @array's elements.
I have tried to uses the following code, with no sucess:
@newarray = $hash{ $w1 }->{ $w2 }->{ words };
I know that was kind of a stab in the dark, but I am having problems figuring out how to extract each individual value of $nw and use it as a key which is then pushed into an array $count times. My thanks and gratitude to anyone who can show me the way to accomplish this.
-moxIn reply to importing all the values stored in an HoH into an array by chinamox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |