A recent node reminded me of a problem I had a while back - how to include some sort of periodically changing data into a module. These are some possibilities I came up with, though I'm sure there are others:

  1. Incorporate the data directly into the module as a data structure, and just update the module when the data changes.
  2. Same, but incorporate it in a __DATA__ section of the module.
  3. Inherit from a separate data module.
  4. Use a separate config data file (text, yaml etc) for the module in @INC. Provide class method to update it.
  5. Provide methods to import and update the data in a config file local to the calling program.

My solution was #1 just for expedience (though it didn't feel quite right), however, the data was from the PNG specification, which shouldn't be expected to change often. Other data such as a list of PPM repositories may be more of a moving target. Especially for a CPAN module, it would seem useful to provide a method to update the data rather waiting for the module author or hacking the module yourself.

I was wondering what others have done, and what might be considered better ways of handling data for modules such as PPM::Repositories, where it's likely that the user would want or need to update the module's data on their own.


In reply to Including periodically changing data with modules by hangon

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.