Let me second this! As usual, mirod knows well what he is saying.

I worked on a project earlier this year that had URIs and paths hardcoded throughout the programs. Whenever one program was moved from testing to production, the original coder had spent several minutes manually editing the paths, as the testing and production environments were different. (They should have been the same, but that is a story for another time.)

One of the first things I did was to write a small module based on Data::Denter. It looked in the same location on the production and testing boxes for a configuration file. It loaded all of the configuration values into a hash and made them available. Then, I removed all of the paths and URIs and put them in the configuration file. Finally, I defined constants in all of the programs, and added code to load the configuration module and to populate the important constants.

This turned out to be an even bigger win in one circumstance. I wanted to do some profiling of some detailed code, so I added debugging sections. Because I didn't want to slow things down in general, I used the if (0) {} trick -- and I could control whether or not the debugging code was stripped by the optimizer simply by changing one value in the configuration file.


In reply to Re: Re: Require Centralized Variables by chromatic
in thread Require Centralized Variables by mhorner

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.