in reply to Re^3: Datastructures to XML
in thread Datastructures to XML
The same way I showed in the previous example. You can nest the cmd:forXXX any way you like. You just have to know which keys/indexes point to arrayrefs, which to hashrefs and which to scalars. And use the cmd:forkey, cmd:forkeys or filter the cmd:foreach or cmd:foreachkey to select/filter them right. The filters specified as the values of the cmd:foreach and cmd:foreachkey attributes are Perl expressions that expect to find the key/index in $_, I'll have to provide access to the value or the whole array/hash as well so that you could filter using the values, butI think it should handle any combination of references. Provided that the data structure is consistent. That is, if it's an array of hashes of something then the value of the key {Foo} in all hashes has the same type.
Plus actually there is no reason why couldn't the cmd:foreach handle plain scalars the same way as a ref to a one element array.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Datastructures to XML
by zentara (Cardinal) on Mar 18, 2009 at 13:09 UTC | |
by Jenda (Abbot) on Mar 18, 2009 at 16:52 UTC |