<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Laufeyjarson writes... &#187; config</title>
	<atom:link href="http://blog.laufeyjarson.com/tag/config/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.laufeyjarson.com</link>
	<description>... notes, thoughts, rants, and randomness.</description>
	<lastBuildDate>Sat, 04 Feb 2012 04:56:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Configuration Files and Config::JFDI</title>
		<link>http://blog.laufeyjarson.com/2009/12/configuration-files-and-configjfdi/</link>
		<comments>http://blog.laufeyjarson.com/2009/12/configuration-files-and-configjfdi/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 23:20:42 +0000</pubDate>
		<dc:creator>Laufeyjarson</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[Config::JFDI]]></category>

		<guid isPermaLink="false">http://blog.laufeyjarson.com/?p=30</guid>
		<description><![CDATA[I wrote this some time ago, and it sat in the queue and got stale.  I&#8217;ve mentioned one place I&#8217;m not using Config::JFDI, but I&#8217;m using it other places and I thought it desrved a mention. I mentioned my old framework had a way to infer which configuration file to use by examining the environment [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this some time ago, and it sat in the queue and got stale.  I&#8217;ve mentioned one place I&#8217;m not using <a title="Config::JFDI" href="http://search.cpan.org/~rkrimen/Config-JFDI-0.05/lib/Config/JFDI.pm" target="_blank">Config::JFDI</a>, but I&#8217;m using it other places and I thought it desrved a mention.</p>
<p>I mentioned my old framework had a way to infer which configuration file to use by examining the environment it was running in.  I&#8217;ve moved to the Catalyst Way of things (more or less) and that will make things easier.  A bunch of my old code can go away.</p>
<p>I have some useful tools to do things which do like to read the config file, too.  They used the same code.  They now use <a title="Config::JFDI" href="http://search.cpan.org/~rkrimen/Config-JFDI-0.05/lib/Config/JFDI.pm" target="_blank">Config::JFDI</a>.  It reads config files the same way Catalyst does, and gives you a very similar $config object you can use to look at things with.</p>
<p>I did have to dig in to the sources to get it to work right, even though it&#8217;s pretty well documented.</p>
<p><span id="more-30"></span></p>
<p>When I run my programs, I usually run them from a shell where I have environment variables set to get the right suffix for my config files.  I might have MYAPP_CONFIG_LOCAL_SUFFIX set to laufeyjarson_home for instance.</p>
<p>There was a case where the utility program needed to force a particular value there, so it would get the right configurations.  I called Config::JFDI-&gt;new with local_suffix=&gt;&#8217;whatever&#8217;, and expected that to work.</p>
<p>It didn&#8217;t seem to. The documentation said it works!</p>
<p>And, it does work.  But it only works if the environment variables are not set.  If the environment is set, that overrides the values set with new().</p>
<p>I almost filed a bug on it, too.  That can&#8217;t be right!</p>
<p>It can, though.  I just had to think it through.  You want your program to have a sensible default coded in.  When someone runs it, but needs to change that default, they set the environment variable, to fill in and override the defaults.  That&#8217;s exactly what it did!</p>
<p>Too bad it isn&#8217;t what I wanted.</p>
<p>Config::JFDI supports an option to new called &#8220;no_env&#8221;, which will tell it not to read the environment.  That would fix it.</p>
<p>I actually went the other way; I changed ${ENV}.  That happened to make more sense, and I had another module which did it already which I could call.</p>
<p>So, Config::JFDI works right, and lets you do whatever you need.  It&#8217;s also really handy to write stand-alone tools with it and have it work like Catalyst does.</p>
<p>I was  considering using it in myapp_server so I can set only MYAPP_CONFIG_LOCAL_SUFFIX or CATALYST_CONFIG_LOCAL_SUFFIX and then put the default values for all the command line options in my config file rather than in four more variables.  Decided not to.  I just set the environment and let it be.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.laufeyjarson.com/2009/12/configuration-files-and-configjfdi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

