title: How to create global variables in Erlang
body: <p>I am writing an ejabberd module to filter packets. I need to get the hostname to pull some configs using <code>gen_mod:get_module_opt()</code>. </p>
  
  <p>I have 4 important functions :</p>
  
  <ol>
  <li><code>start(Host, _Opt)</code> : This is an ejabberd function to load my module. I get the <code>Host</code> atom here</li>
  <li><code>filter_packet({From, To, XML})</code>: This is my packet filter hook. I cannot pass custom params to this function, as it is a hook in ejabberd.</li>
  <li><code>get_translation(XmlData)</code>: <code>filter_packet()</code> calls <code>get_translation()</code> in a loop</li>
  <li><code>fetch_translation(XmlData)</code>: called recursively from <code>get_translation()</code>. This is where I am calling <code>gen_mod:get_module_opt()</code>, and hence need the <code>Host</code>.</li>
  </ol>
  
  <p>My question is, how can I take <code>Host</code> from <code>start()</code> and put it in a global variable, so that <code>fetch_translation</code> can access it?</p>