Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^5: My preferred way of handling config data in Perl is:

by Anonymous Monk
on Dec 19, 2006 at 15:43 UTC ( #590687=note: print w/replies, xml ) Need Help??

in reply to Re^4: My preferred way of handling config data in Perl is:
in thread My preferred way of handling config data in Perl is:

True, but something like a database connection string does need to be different for each build-environment you run in, ie you will surely not want the development code connecting to your production database, for example.

There are a lot of ways to handle this sort of thing; some involve external configuration files, some don't.

One way is to always run the database programs on the same machine as the database server; this means that you can just connect to "localhost", and reach the right database.

Another method is to have your program detect which host you're running on, and set the database on that basis: when running on machine 'prod', connect to 'prod_database', when running on machine 'test', connect to 'test_database', and so forth.

You can also just do your database configuration in your DNS and/or /etc/hosts file; a configuration system that you (or your sysadmin) is probably already using. In this method, you always connect to the host "database_server": but that hostname points to different IP addresses on different on different machines.

Or, as you pointed out, you can just use any number of the other config file methods to specify different results on different machines.... do whatever works for you...

  • Comment on Re^5: My preferred way of handling config data in Perl is:

Replies are listed 'Best First'.
Re^6: My preferred way of handling config data in Perl is:
by f00li5h (Chaplain) on Dec 20, 2006 at 10:20 UTC

    Anonymous Monk:... use config file or DNS sillyness...

    Yes, those both would do the trick, although I'd prefer the config file, as I'd like to be sure that my hosts were connecting to the right database... just so I can have something in flashing red text to say `this is the development database, and the development code base - expect things to act stupid' so I know to expect stupid behaviours and missing data

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590687]
[stevieb]: hey, thezip
[perldigious]: I don't miss having to drive up and down in elevation on roads that are iced over, I white knuckled gripping the steering wheel every time I had to where I used to live.
[perldigious]: So I don't envy you mountain guys if you have to drive in the winter, even with tire chains.
MidLifeXis waves.
[stevieb]: man, I absolutely LOVE driving in the worst winter conditions. In the mountainous roads, there are extremely few (if any) other drivers. I love the challenge. I've been doing extreme off-road my whole life, and as I said, I'm always well...
[stevieb]: ...prepared for even the very worst
Discipulus seems a part of the globe very unfrindly with Kawasaki riders..
[thezip]: My doggies love it when it snows
[perldigious]: As long as you are a good "boy scout" stevieb, more power to you... but I like my Jeep, and don't like the idea of rolling it or crashing it in to anything. :-)
[thezip]: Me, not as much.

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2016-12-06 16:46 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (112 votes). Check out past polls.