<?xml version="1.0" encoding="windows-1252"?>
<node id="994074" title="Re: Refactoring conf-driven app into a module; what to do with the config?" created="2012-09-17 14:36:38" updated="2012-09-17 14:36:38">
<type id="11">
note</type>
<author id="72516">
blue_cowdawg</author>
<data>
<field name="doctext">
&lt;ul&gt;&lt;ul&gt;&lt;i&gt;

&lt;/i&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;
As [moritz] already pointed out, if the information is static then what you have is a data file.  In that event why not embed it into your module somehow?  
&lt;/p&gt;
&lt;p&gt;
If the end user is expected to modify the information somehow (DB name, DB host, user, password et. al.) then you should be using a configuration file.  YAML, JSON, XML or just a good old fashioned text file with key value pairs is good. Another technique I've seen more than once is to create a file that looks a lot like a Perl module (in fact is) or plain Perl code to be read. Example:
&lt;code&gt;
package MyConfig; 

#
# For the record:  fixed the following 4 lines since my fingertips decided to do something 
# other than what my brain was telling them to.   s/my/our/ 
our $datahost="blah.foo.com";
our $datauser="user";
our $password="s3cr3t";
our $database="thedata";

1;
&lt;/code&gt;
which is then used thusly:
&lt;code&gt;
   |random handwaving here...
use MyConfig;

my $host=$MyConfig::datahost;
my $user=$MyConfig::datauser;
my $pass=$MyConfig::password;
my $database=$MyConfig::database;

   | now do something with it...
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
Personally for my own uses I use XML files and [cpan://XML::Simple] to load them.
&lt;/p&gt;

&lt;div class="pmsig"&gt;&lt;div class="pmsig-72516"&gt;
&lt;hr&gt;
&lt;font size="-2"&gt;

Peter L. Berghold  -- Unix Professional&lt;br&gt;
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg&lt;br&gt;
&lt;/font&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
994067</field>
<field name="parent_node">
994067</field>
</data>
</node>
