I have the following file structure:
|_controllers
| |___FooController.pm
|_models
| |___Foo.pm
|_utils
| |___BarUtils.pm
|_foobar.do
I want to know how can I import the modules between files, let say that I want to use Foo.pm on FooControllers.pm or use BarUtils.pm on foobar.do . When I have the files on the same directories I just do
use Foo;
But in this case I cannot figure out how to do it.
You need to make sure that:
The parent directory (the one that contains
controllersetc..) is in@INCThe modules would then be named:
The exact rationale for how and why this works (as well as
@INCdetails) can be found on SO:How is Perl's @INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)
How does a Perl program know where to find the file containing Perl module it uses?