$ListOfItems = {
'0001' => {name => $naam, category => ['Sport,SeaSport', 'Location,Island,Crete']},
'0002' => {name => 'Hotel Beta', category => ['Sport,SeaSport', 'Location,Mainland,Pilio']},
'0003' => {name => 'Hotel Gamma', category => ['Sport,WinterSport', 'Location,Mainland,Pilio']},
'0004' => {name => 'Hotel Delta', category => ['Sport,WinterSport', 'Sport,SeaSport', 'Location,Mainland,Pilio']},
'0005' => {name => 'Hotel Epsilon', category => ['Sport,WinterSport', 'Location,Mainland,Olympus']},
'0006' => {name => 'Hotel Zeta', category => ['Location,Mainland,Olympus']},
}; After this initial creation and initialization of the data structure, I'm trying to dynamically add elements to it from the contents of a SQL query. This is where I'm having problems though; the script does not the entry that is supposed to be created by following statement:
$ListOfItems{'0007'} = {name => 'Hotel Delta', category => ['Sport,WinterSport', 'Sport,SeaSport', 'Location,Mainland,Pilio']}; Can anyone tell me the correct syntax for adding elements to this data structure and supply me with additional information on what kind of data structure it is? I'm currently thinking its a hash of arrays, is this correct?
Thanks in advance.
$ListOfItems->{'0007'} = {name => 'Hotel Delta', category => ['Sport,WinterSport', 'Sport,SeaSport', 'Location,Mainland,Pilio']}; This is a mixed structure: $ListOfItems is a hash reference (so you need the -> to access its elements), and each value of $ListOfItems is also a hash refrence. The 'name' key has a plain scalar value, and the 'category' key's value is an array reference.