<?xml version="1.0" encoding="windows-1252"?>
<node id="998439" title="Re^2: Export from module in subdirectory" created="2012-10-11 08:56:44" updated="2012-10-11 08:56:44">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;You're looking at it backwards. Don't decide on the code because of the filenames; decide on the filenames because of the code.&lt;/p&gt;

&lt;p&gt;Choose a meaningful package name, like "Quux::Enhancer", and declare the package name in the module (somewhere near the top - the only things it makes sense to put before the package declaration are lexical pragma like &lt;c&gt;use strict; use warnings; use 5.010;&lt;/c&gt;) using:&lt;/p&gt;

&lt;c&gt;
package Quux::Enhancer;
&lt;/c&gt;

&lt;p&gt;Now decide on which lib dir it's going to live inside. Often this will be a directory which is in perl's default &lt;c&gt;@INC&lt;/c&gt; list. Within that directory create a subdirectory called &lt;b&gt;Quux&lt;/b&gt;, and within that save your module as &lt;b&gt;Enhancer.pm&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;Then in your script, if that lib dir is not in perl's default &lt;c&gt;@INC&lt;/c&gt;, include this:&lt;/p&gt;

&lt;c&gt;
use lib '/path/to/lib';  ## not including 'Quux'!!
&lt;/c&gt;

&lt;p&gt;And then in the script load the module like this:&lt;/p&gt;

&lt;c&gt;
use Quux::Enhancer;
&lt;/c&gt;

&lt;p&gt;If you ever need to move the file, then that's fine; no need to change anything within the module; just make sure it's always called &lt;b&gt;Enhancer.pm&lt;/b&gt;, and always kept in a directory called &lt;b&gt;Quux&lt;/b&gt;. Then &lt;c&gt;use lib&lt;/c&gt; to tell your Perl script where to find it.&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
998052</field>
<field name="parent_node">
998219</field>
</data>
</node>
