I don't have time to code a solution write now, but I have time to comment on the structure you wish the parser to output.
What's the point of having an array that always contains execatly one hash reference? [ { ... } ] should be replaced with { ... }.
Why does the structure contain more information than the configuartion file? Specifically, indexes 0 and 1 acquired names domain1 and domain2 during parsing. This doesn't add any usefulness, and is misleading because domain2 could appear before domain1 when iterating over the hash. If you need to convert indexes into numbered names for output/display purposes, do it in the output/display code.
The following structure contains all the information as yours, but is more concise. Simpler is almost always better.
@domains = ( { 'libname' => 'foo', ... 'options|roptions' => { 'datapath' => [ ... ], 'indexpath' => [ ... ], 'workpath' => [ ... ], 'metapath' => [ ... ], }, }, { 'libname' => 'bar', ... 'options|roptions' => { 'datapath' => [ ... ], 'indexpath' => [ ... ], 'workpath' => [ ... ], 'metapath' => [ ... ], }, }, );
In reply to Re: Parsing a complex config file
by ikegami
in thread Parsing a complex config file
by solitaryrpr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |