it would be good to configure the application quite fast
You may be trying to optimize something on the basis of some perceived speed gain that is just not there or which makes no difference. Unless you have some really special requirement, anything that you do is going to be just fine speed wise.

I don't really understand enough from your description of what you are trying to configure, but you may find that some standard modules will suit your purpose quite well. I would not put code into a file that a user is going to edit!

For something that a user might muck with, I find the series of Config* modules to be quite nice. They implement a HoH or HoHoH structure which can be accessed easily. Although sometimes I put my own module as a thin "wrapper" around that so that I wind up with something that just looks like a rocket fast DB. So instead of having a predefined variable in my code, I call my @filehistory = getdb('filehistory') or whatever when I need it.

I do have modules that init themselves by reading complicated hereis documents or other structures. That is fine too. For example one table I have has changed once in the last 20 years(existed before current Perl code) - and required coding changes to deal with the ramifications. Its just fine to put something like that in a program module that only somebody on the programming team should be messing with!

I have other modules that read in thousands of lines of data information and present a simple I/F to the rest of the code - but this isn't in the range of what I could call "configuration" - this is operational data.

Sorry to be long winded. But, either make a module that is part of "your" code and you "own" or make some sort of file (Config style or YAML, etc) that contains no code at all. Avoid putting your code into some user modifiable file.


In reply to Re: Making use of a config file written in Perl by Marshall
in thread Making use of a config file written in Perl by noodleish

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.