Where should I place functions like, for example, sum_it_all() in Catalyst project?
It’s not a model, that’s nothing about data, it’s not a controller because it doesn’t ask the web-request. It’s just a simple function and I want it to be accessible in all my controllers.
Now I use Model/Utils.pm and $c->model("utils")->sum_it_all(), but it seems to be really ridiculous.
If you need this functions in a Catalyst Controller, just embed it in the controller where you need it. If you need the same function in several Controller. Create a new Module that contains all your functions. If your Project is named “Foo”, then create for example “Foo::Helpers”.
In every controller where you need some functions from your helper just import them “use Foo::Helper qw(sum)”
Look at Sub::Exporter for exporting functions.