Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Best practice for configuration variables stored in external file

by McA (Curate)
on Sep 06, 2013 at 07:20 UTC ( #1052660=note: print w/ replies, xml ) Need Help??


in reply to Best practice for configuration variables stored in external file

Hi,

I think your solution is not completely wrong. Put your constants into one or more perl modules an use (not import) them where you need it without polluting the namespace. Why shall a textfile which gets parsed by a module be better than a textfile (.pm) which gets parsed by perl itself?

The question is: Do you need the ability to reconfigure at runtime (Constants are constant, aren't they)? Are the config constants bundled in a way, so that these constants belong to a component of your program. But this is the same problem as cutting your program into meaningful pieces (modules).

Opinions from the illuminated monks appreciated.

Best regards
McA


Comment on Re: Best practice for configuration variables stored in external file
Re^2: Best practice for configuration variables stored in external file
by afoken (Parson) on Sep 06, 2013 at 19:33 UTC

    Constants belong into the code. Configuration options don't.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      I think then that I'm talking about "constants", not "configuration variables". They are not, at any point, edited from within the script.

      Would "use Module" then be the best way to handle this?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052660]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2014-09-17 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (100 votes), past polls