Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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...


In reply to Re^5: My preferred way of handling config data in Perl is: by Anonymous Monk
in thread My preferred way of handling config data in Perl is: by rinceWind

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-19 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found