title: Catalyst: how declare a global subroutine
body: <p>Hi i don't want to repeate the same code in the controllers, so i created a sub in the main MyApp package:</p>
  
  <pre class="lang-perl prettyprint-override"><code>sub do_stuff {
      my $input = shift;
  
      do something
  }
  </code></pre>
  
  <p>But then i want to use it in controller <code>MyApp::Controller::Foo</code></p>
  
  <pre class="lang-perl prettyprint-override"><code>sub test : Chained('base') Args(0) {
      my ($self, $c) = @_;
  
      my $test = do_stuff($c-&gt;request-&gt;params-&gt;{s});
  
      do something more
  }
  </code></pre>
  
  <p>i get following error:</p>
  
  <blockquote>
    <p>Caught exception in MyApp::Controller::Foo->test "Undefined subroutine
    &amp;MyApp::Controller::Foo::do_stuff called at
    /home/student/workspace/MyApp/script/../lib/MyApp/Controller/Foo.pm
    line 24,  line 1000."</p>
  </blockquote>
  
  <p><strong>How can i create a subroutine / function to use global in all Catalyst Controllers???</strong></p>