<br><br><div class="gmail_quote">On Tue, Feb 22, 2011 at 1:50 AM, John Ricker <span dir="ltr"><<a href="mailto:sephtin%2Bpm-talk@gmail.com">sephtin+pm-talk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><div class="gmail_quote">On Tue, Feb 22, 2011 at 2:08 AM, Mike South <span dir="ltr"><<a href="mailto:msouth@gmail.com" target="_blank">msouth@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div><div></div><div>On Mon, Feb 21, 2011 at 10:21 PM, John Ricker <span dir="ltr"><<a href="mailto:sephtin@gmail.com" target="_blank">sephtin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div></div></blockquote></div></div></div></blockquote><div> </div><div>[snip]</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div>Re: the "bash'ish" way... was the only way I could come up with that didn't load everything regardless of what I needed... other than splitting up each theme into separate files, which I'm trying to avoid.</div>
<div>My failure was with use(), since it required path at runtime (using lib) which I couldn't provide at compile time as the path is a variable defined in the file.</div><div>I DID attempt require, but wasn't able to pass the variable to the config file. I must have been doing something wrong because after checking Mike's example and switching things back for require, it seems to be working... I'll probably comment it out, and try what seems to be the most recommended method... just hashing everything, and reading it that way... good learning experience at the very least... :)</div>
<div><br></div></div></blockquote><div><br></div><div>I just looked through the example and realized I had forgotten to cut part of it out. Sorry if this was confusing. The "$which_dir" variable should be removed completely, in favor $theme_sub_dir. The idea was to show that $theme_sub_dir wasn't known until runtime (since it's being pulled in from the environment), and demonstrate how to require() something from that dynamically-determined dir. The $which_dir variable was from when I was making sure I was right about how I thought it worked :). Change that section to look like this:</div>
<div><br></div><div><meta charset="utf-8"><span class="Apple-style-span" style="border-collapse: collapse; font-size: 13px; "><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">#comment this out </font></div>
<div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">#our $which_dir = 'bob';</font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace"><br>
</font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">$which_config = 'one';</font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">#$which_config = 'two';</font></div>
<div style="font-family: arial, sans-serif; "><font face="'courier new', monospace"><br></font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">my $theme_sub_dir = $ENV{theme} || die "set theme in the env like this: theme='test' $0\n";</font></div>
<div style="font-family: arial, sans-serif; "><font face="'courier new', monospace"><br></font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">my $full_path_to_require = "/Users/msouth/$theme_sub_dir";</font></div>
<div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">die "there is not a directory called $full_path_to_require" unless -d $full_path_to_require;</font></div><div style="font-family: arial, sans-serif; ">
<font face="'courier new', monospace">push @INC, $full_path_to_require;;</font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace"><br></font></div><div style="font-family: arial, sans-serif; ">
<font face="'courier new', monospace">#just use the file name since @INC has been modified </font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">#require "$which_dir/<a href="http://set_up_bob.pl/" target="_blank" style="color: rgb(0, 0, 204); ">set_up_bob.pl</a>";</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div style="font-family: arial, sans-serif; "><font face="'courier new', monospace">require "<a href="http://set_up_bob.pl">set_up_bob.pl</a>"; # require "$full_path_to_require/<a href="http://set_up_bob.pl">set_up_bob.pl</a>" would work here, too</font></div>
<div style="font-family: arial, sans-serif; "><font face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">mike</font></div>
</span></div></div>