Overriding function in module in Lua 5.1
<p>I'm writing a Lua program, in which there are lots of modules that is independent from each other. Every module keeps related source files in its folder. What I want is to override <code>require</code> function in each module so that when <code>require</code> called, file in module folder is loaded.</p>

<p>Assume that I have modules below and each of them has a file named <code>utils.lua</code>:</p>

<pre><code>src
├── module1
│   ├── main.lua
│   └── utils.lua
├── module2
│   └── utils.lua
├── module3
│   └── utils.lua
└── utils.lua
</code></pre>

<p>and I'm writing <code>module1.main</code>. I want ability to write something like</p>

<pre><code>require 'utils' -- load module1.utils actually.

-- Do something...
</code></pre>

<p>Any good idea?</p>

<p>Notes: I need <code>require</code> for I have some custom searchers.</p>