What I'm wondering is whether this is considered good Perl coding practice?

I think you're asking the wrong question. You should consider asking (yourself) the following:

  1. Does it work?

    Given this is an existing project, I'm gonna assume the answer is yes.

    So then you have to ask yourself: what are the risks involved with changing it?

  2. Is it difficult to maintain?

    Reading between the lines of your description, I'm gonna assume the answer is no.

    If you need to change the value of an existing configuration parameter, you go into the .pm file and edit it.

    If you need to add a new one, you edit the .pm file and add it.

    That doesn't sound particularly hard to me. In fact, it sounds identical to the process of maintaining a configuration file in some other format--say YAML.

    But--and here is the crux of my argument--when you've made changes, validation is as simple as:

    perl -c configModule.pm

    And if the editor forgets to validate, the error will be detected immediately at program startup, as a Perl syntax error, with the clarity of Perl's syntax error messages.

    Ask yourself:

    How good are the the equivalent error messages for your prospective config file alternative?

    How good is the beta test cycle of your prospective config file format parser (say YAML), compared to that of Perl parser itself?

Many will condemn the existing mechanism as "crude". But crude is often a euphemism for 'simple'. And there is very little wrong with simple.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re: Should you use a module to hold configuration items? by BrowserUk
in thread Should you use a module to hold configuration items? by romandas

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.