Repository navigation
noob q: external modules #2312
|
Hi! I am fairly new to Mojolicious and am working on an app that will accept an uploaded file and display some details about that file. I have already written a module to parse these files and I believe I should have it under lib/MyApp/Model, but where to I put the "use" declaration (I assume in the main package under lib) and then do I need to declare a "helper" to use a command from the module? |
Replies: 1 comment 6 replies
|
Hi there and welcome to Mojolicious. ;) To help you with this, it basically boils down to two options:
It may make sense to register a helper for your module, if you need to access it from multiple locations in your app or if it depends on configuration values. Because a helper my access many usefull objects like the "Mojolicious::Plugin::Config"-Instance. |
For
use MailDatEditor::Model::MAILDAT qw( maildat_report );to import a usable functionmaildat_report, there must be a module atMailDatEditor/Model/MAILDAT.pmwithin one of the directories added to your lib paths, which starts withpackage MailDatEditor::Model::MAILDAT;, and which includessub maildat_report,use Exporter 'import';, andour @EXPORT_OK = 'maildat_report';, or similar.