I have two modules:
./My/Module1
./My/Module2
Module1
is using subroutines from Module2
. So in my script i typed following:
use My::Module1
use My::Module2
But this does not worked and perl complained that subroutines which are used from Module2
by Module1
does not exists. So I added following line to Module1
:
use My::Module2
Finally this worked as expected.
I am wondering if there is some solution that will include all modules from specified sub-directory tree and solve dependencies automatically. I do not want to type use
keyword in modules which depends on another modules. Following commands was tried but it did not worked (either by syntax errors or it used wrong modules):
use My::;
use My::*;
use My;
Also I would ask if this cross-using modules and calling it's subroutines is considered as a good practice in perl programming?
PS: @INC
contains current directory so loading modules is working.
PPS: Modules used Exporter
Then type the
BEGIN
,require
, andimport
keywords instead?Seriously, there's no good way for this to work. Just use
use
in each module so that it can load the things it needs.Yes. Modularization is considered good practice in all programming.