Hash of hashes, of hashes, of arrays of hashes
- From: Tim O'Donovan <timodonovan@xxxxxxxxxxx>
- Date: Thu, 27 Oct 2005 18:05:33 +0100
Hi,
I'm trying to create a data structure that will (eventually) make it easier to create a series of slightly different XML documents. The structure will effectively hold a template.
Here's a section of code I am stuck on:
#!/usr/bin/perl -w
use strict; use Data::Dumper;
my %xmldoc = (
doc1 => {
customer => [{name => 'count', format => 'int'},
{name => 'unit', format => 'text'},
],
order => [{name => 'expected', format => 'date'},
],
},
#etc
);
The problem I am having is determining how many keys are present in:
$xmldoc{doc1}and how many elements are present in:
$xmldoc{doc1}{customer}and so on.
I was then planning on looping through each section and using the data to contruct the XML.
For reference, here is the dumped output of %xmldoc:
$VAR1 = 'doc1';
$VAR2 = {
'customer' => [
{
'format' => 'int',
'name' => 'count'
},
{
'format' => 'text',
'name' => 'unit'
}
],
'order' => [
{
'format' => 'date',
'name' => 'expected'
}
]
};Any advice would be greatly appreciated.
Thanks.
Kind regards, Tim O'Donovan .
- Follow-Ups:
- Re: Hash of hashes, of hashes, of arrays of hashes
- From: robic0@xxxxxxxxx
- Re: Hash of hashes, of hashes, of arrays of hashes
- From: xhoster
- Re: Hash of hashes, of hashes, of arrays of hashes
- From: Anno Siegel
- Re: Hash of hashes, of hashes, of arrays of hashes
- Prev by Date: Re: stat() bug
- Next by Date: Re: stat() bug
- Previous by thread: Re: stat() bug
- Next by thread: Re: Hash of hashes, of hashes, of arrays of hashes
- Index(es):
Relevant Pages
|