in reply to Adding a hash to a hash reference.
Regarding your extra brackets, try using
I haven't used XML::Simple myself but judging from your sample I think this will do what you want.my $hash_add = { $cat => [{ 'name' => "$name", 'link_name' => "$link_name", 'description' => "$desc", 'date' => "$today_date" }] }; for (keys %$hash_add) { $xml->{policies}->[0]->{$_} = $hash_add->{$_}; }
Regarding your sort issue I think you want the extra brackets. In fact, they should all be in own brackets, it seems like. Again, I haven't use XML::Simple myself, but if you have a hash with the category as hash, you don't get it sorted. If you store the category alongside name, date, etc you can have each item represented as a hash (as you do now) and store all the hashes in an array, sorted.
Hope this helps,
ihb
Read argumentation in its context!
|
|---|