++ to GrandFather for asking about the wider problem.

It seems like the first question here is figuring out how the data in file format 1 maps to the data in file formats 2,3,4, etc. To work out this problem I would:

  1. Do a data model of each file format
  2. Note differences in terminology and cardinality of relationships. For example, is "category" in format 1 equivalent to "menu" in format 2? Does format X allow for recursive menus? Does format Y? Can a menu item belong to more than one menu? And so on.
  3. Note differences in data available for each format. For example, file format 2 appears to have four bits of information per menu item, whereas format 1 has only two (assuming each name/icon corresponds to a menu item)
  4. Define a standard data model that represents all available data
  5. For formats with missing information define defaults

And now that you have worked out the design issues, you can start thinking about how to morph file formats one into another. For a given format X and Y, this will involve two steps:

  1. Read in a file in format X and convert its data to the standard data model
  2. Traverse the standard data model to output the data in format Y.

You will need a read_format_to_standard() subroutine for each input format and a write_format_from_standard() routine for each output format. But without a good idea of the standard and how each format maps to it, you will be running in circles writing any of these.

Best, beth


In reply to Re: Building an arbitrary-depth, multi-level hash by ELISHEVA
in thread Building an arbitrary-depth, multi-level hash by Anonymous Monk

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.