How about this?  Build a giant hash containing all of your config options (using Config::File) and move the current config&#39;s logic to the main script to choose the branch of the hash that corresponds to your particular set of options.<div>
<br></div><div>%Options = (</div><div>  first =&gt; { opt1 =&gt; val1, opt2 =&gt; val2},</div><div>  second =&gt; {opt1 =&gt; val3, opt2 =&gt; val4}</div><div>);</div><div><br></div><div>if ($selection eq &#39;first&#39;) {</div>
<div> %RelevantOptions = %{ $Options{&#39;first&#39;} };</div><div>}</div><div><br></div><div>etc.</div><div><br><div class="gmail_quote">On Tue, Feb 22, 2011 at 1:57 AM, Matt Nash <span dir="ltr">&lt;<a href="mailto:mattnashbrowns@gmail.com">mattnashbrowns@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Oops, now I see that the real problem is conditional logic in the config file.  Without knowing all the details of what you are trying to do, that kind of seems like a bad idea.  I&#39;m sure you have a good reason for it.<div>
<div></div><div class="h5"><br>
<br><div class="gmail_quote">On Tue, Feb 22, 2011 at 1:56 AM, Matt Nash <span dir="ltr">&lt;<a href="mailto:mattnashbrowns@gmail.com" target="_blank">mattnashbrowns@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Would Config::File work for you?<div><a href="http://search.cpan.org/~gwolf/Config-File-1.50/lib/Config/File.pm" target="_blank">http://search.cpan.org/~gwolf/Config-File-1.50/lib/Config/File.pm</a></div><div><br></div><div>

<a href="http://search.cpan.org/~gwolf/Config-File-1.50/lib/Config/File.pm" target="_blank"></a>There is a well-respected &quot;Perl Best Practices&quot; book which some jerk seems to have put up on the web in its entirety.  If you search for the title and &quot;config file&quot; you will find some helpful guidelines to reading and writing config files in Perl, but I&#39;m not linking to it.</div>


<div><br><div class="gmail_quote"><div><div></div><div>On Mon, Feb 21, 2011 at 11:21 PM, John Ricker <span dir="ltr">&lt;<a href="mailto:sephtin@gmail.com" target="_blank">sephtin@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>
Just having converted a bash script to Perl, ran across a couple issues, and thought maybe sending to the list might obtain a nudge in the right direction.. :)<div><br></div><div>The issue I&#39;m currently trying to tackle is pulling in config info.</div>



<div>I have a config information I want to include, but it&#39;s dependent on a variable(s) set in my script.  In bash, I&#39;d just source the file, and it&#39;d go through the if statements, and all is well.  In Perl, I can&#39;t seem to tackle it...</div>



<div><br></div><div>Example:</div><div>#<a href="http://main.pl" target="_blank">main.pl</a></div><div>if (stuff) {</div><div>    $varsneeded = &quot;first&quot;;</div><div>}</div><div>elsif (otherstuff) {</div><div>    $varsneeded = &quot;second&quot;;</div>



<div>}</div><div>else {</div><div>    $varsneeded = &quot;last&quot;;</div><div>}</div><div><br></div><div>&lt;need to read in variables here&gt;</div><div>&lt;then do stuff with variables&gt;</div><div><br></div><div>---x---</div>



<div>#configFile:</div><div>if ($varsneeded eq &quot;first&quot;) {</div><div>    $var1 = &quot;1&quot;;</div><div>    $var2 = &quot;2&quot;;</div><div>    ...</div><div>}</div><div>elseif ($varsneeded eq &quot;second&quot;) {</div>



<div>    $var1 = &quot;somethingelse1&quot;;</div><div>    $var2 = &quot;somethingelse2&quot;;</div><div>    ...</div><div>}</div><div><br></div><div>You get the idea.</div><div><br></div><div>So, I&#39;ve tried:</div><div>



--use:  Did testing with use, and thought it was my answer, but unfortunately the directory that I need to grab the config file(s) from is set from a variable... which isn&#39;t defined until after compile time, so use doesn&#39;t seem to be an option.</div>



<div>--do/require:  Can&#39;t seem to find a way to pass the $varsneeded variable into the config file(s) (.pl, .pm, .whatever) when using do or require.  If there&#39;s an example out there of this, then somehow google has not been kind enough to enlighten me.  :P</div>



<div>--eval `config file`: variable to the config file, same issue as do/require attempts.</div><div><br></div><div>Obviously I&#39;ve oversimplified the example.  The script is over 1200 lines, so simplified for good reason.  Looking for best practice kind of thing here.. if more detail is needed (I expect it may come to that).. I can fill in a lot of blanks, just need to know what info might be helpful.</div>



<div><br></div><div>More info--</div><div>After some thought, and after re-reading my question.. thought some additional info might be helpful.</div><div><br></div><div>The script is for creating custom themes.  I&#39;m taking choices made on a php page that are passed to the script, and the script is pulling in variables based on those choices... and some other factors.. :P</div>



<div>Each section is approx. 26 variables right now, and there are 19 different possible options with another dozen or two coming soon.</div><div><br></div><div>MY answer to this all, is to break up the config file into a file for each option, and just pull in the appropriate file... But as this beast grows, I&#39;d REALLY like the convenience of a find/replace in ONE file when something changes, instead of 50 or more!</div>



<div><br></div><div><div>Thanks in advance for any assistance!</div><div>-John (sephtin @gmail)</div><div><br></div></div>
<br></div></div>_______________________________________________<br>
Raleigh-talk mailing list<br>
<a href="mailto:Raleigh-talk@pm.org" target="_blank">Raleigh-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/raleigh-talk" target="_blank">http://mail.pm.org/mailman/listinfo/raleigh-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br>
</div></div></blockquote></div><br></div>