Hi I have a hash that looks somthing like this. This has was generated using a RoseDB call to a database and then condensed using looping :
$data = 'Default'=> {
'Record' => {
'PInner' => 1,
'LOuter' => 1,
'POuter' => 1,
},
'Elect' => {
'LTurn' => 1,
'RTurn' => 1,
'L'=> 1,
'R'=> 1,
},
}
I have to make an unordered list from it which would look something like:
<ul>
<li>Default
<ul>
<li>Record
<ul>
<li>PInner</li>
<li>LOuter</li>
<li>POuter</li>
</ul>
</li>
<li>Elect
<ul>
<li> LTurn </li>
<li> RTurn </li>
<li> L </li>
<li> R </li>
</ul>
</li>
</ul>
</li>
I can simply loop through this and make a long cluttered piece of code. But the problem arises when i try to make it generic, and instead of having 3 levels i have "n" levels. So So I was think of looping using recursion . Is it possible in anyway to make that happen
Please advice Thanks
You cannot assign a hash without parentheses (to a hash variable) or curly brackets (to a scalar variable).
This does what you want, just keep in mind that hash keys are not ordered, so the items in the lists might come out in a different order. If it is a problem, use arrays instead of hashes.