Elixir - Call method on module by String-name : <p>I'm pretty new to Elixir and functional programming-languages in general.</p>

<p>In Elixir, I want to call one specific function on Modules, given the Module name as String.</p>

<p>I've got the following (very bad) code working, which pretty much does what I want to:</p>

<pre><code>module_name = elem(elem(Code.eval_file("module.ex", __DIR__), 0), 1)
apply(module_name, :helloWorld, [])
</code></pre>

<p>This (at least as I understand it) compiles the (already compiled) module of <code>module.ex</code> in the current directory. I'm extracting the modules name (not as a String, don't know what data-type it actually is) out of the two tuples and run the method <code>helloWorld</code> on it.</p>

<p>There are two problems with this code:</p>

<ol>
<li><p>It prints a warning like <code>redefining module Balance</code>. I certainly don't want that to happen in production.</p></li>
<li><p>AFAIK this code compiles <code>module.ex</code>. But as module.ex is already compiled and loaded, it don't want that to happen.</p></li>
</ol>

<p>I don't need to call methods on these modules by filename, the module-name would be ok too. But it does have to by dynamic, eg. entering "Book" at the command line should, after a check whether the module exists, call the function <code>Book.helloWorld</code>.</p>

<p>Thanks.</p>
