As others have said, the "problem" is too vague. But just in case it actually involves handling data files that serve specific, predictable, pre-established functions -- such as "address.list", "invoice.table", "personnel.file", "product.inventory", or stuff like that -- a decent approach would be to create a separate module for each type of data.

Each module knows how to read, modify and save it's own type of data, and when a script uses a module and invokes one of it's methods, the associated data file is read just once, and can be used, updated and saved back to disk as often as you want during the lifetime of any one process.

If there are multiple steps in a given process that use a given type of file, the corresponding module will always have its current state and content already loaded as module-internal data, with appropriate "getters" and "setters" (and other convenience functions as you see fit) tailored to that type of file.


In reply to Re: Discussion(maybe?) How would you do this? Modules and reading a file/dir by graff
in thread Discussion(maybe?) How would you do this? Modules and reading a file/dir 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.