http://qs321.pair.com?node_id=127701


in reply to Coding Perl With Style

"config.pm" is not a good name for a module. "Config.pm" is a built-in module to perl. Names beggining with lowercase letters should be considered reserved for pragmas; they are considered "special". "Something::Config" would probably be okay, however.

As for your actual question, you could probably make an object that encapsulated this configuration stuff , or (updated) and have your exsiting classes have it as an instance "variable". Or you could, as you suggested, just pass it as an argument to every function. I see no problem with either of these approaches; it is far cleaner then having your code not be so reuseable and modular.

If I declare a scalar as a constant in a module then export that scalar will it remain a constant?

"constants", as you are referring to, are actually functions that have a prototype of () (explictly no arguments), and thus are inlined by perl. You will get this optimization as long as the function is imported (so perl what to use and that it should inline it) when the relevant code is compiled.