Plan B was going to be to go with an XML config file...

You mean something like this?

$ cat test.xml <?xml version="1.0"?> <filelist> <file name="file1"> <field name="field1" start="50" length="20"/> <field name="field2" start="80" length="20"/> <field name="field3" start="100" length="20"/> </file> <file name="file2"> <field name="field1" start="52" length="22"/> <field name="field2" start="82" length="22"/> <field name="field3" start="120" length="22"/> </file> <file name="file3"> <field name="field1" start="53" length="23"/> <field name="field2" start="83" length="23"/> <field name="field3" start="130" length="23"/> </file> </filelist> $ perl -MXML::Simple -MData::Dumper -e '$x=XMLin("test.xml"); print Du +mper($x)' $VAR1 = { 'file' => { 'file2' => { 'field' => { 'field1' => { 'length' => '22' +, 'start' => '52' }, 'field2' => { 'length' => '22' +, 'start' => '82' }, 'field3' => { 'length' => '22' +, 'start' => '120' } } }, 'file1' => { 'field' => { 'field1' => { 'length' => '20' +, 'start' => '50' }, 'field2' => { 'length' => '20' +, 'start' => '80' }, 'field3' => { 'length' => '20' +, 'start' => '100' } } }, 'file3' => { 'field' => { 'field1' => { 'length' => '23' +, 'start' => '53' }, 'field2' => { 'length' => '23' +, 'start' => '83' }, 'field3' => { 'length' => '23' +, 'start' => '130' } } } } };
But... what? Looks pretty simple to me. I'd rather not have all those data values hard-coded in the perl script itself, and reading them from a basic xml file seems like a no-brainer.

I guess it's a little goofy that there are two layers in XML::Simple's "default" hash structure that are sort of useless ("file" and "field"), but if you tried a different way of structuring the xml (and/or spent some time with the XML::Simple man page), you could probably improve on that. (Or you could just use the default as-is and get done quicker.)


In reply to Re^3: Modelling a data structure by graff
in thread Modelling a data structure by sch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.