We are factoring out the common code from our Perl project. One main program should be split into several re-usable modules.
Our program name is validate_results.pl
which contains set of validation commands. We are planning to split this into small modules so that validate_results.pl
should be like:
use Common::Validate_Results;
use Common::Validate_Results::CommonCommands;
use Common::Validate_Results::ReturnCodeValidation;
...
As per my understanding I should create a Common folder and under that Validate_Results.pm
should be present. Again under Common
, Validate_Results
folder should be created and under that CommonCommands
and ReturnCodeValidation
folders should be present.
Is it mandatory that all these folders should be present or can we have all the Perl programs in a single folder and logically group them and still use the above way to access the modules (say use common::validate_results
like that).
The filesystem hierarchy is required. A::B::C will always be located in A/B/C.pm, somewhere in @INC.
If you have to get around this, read perldoc -f require, specifically looking for the section about subroutine references in @INC. Yes, you can make the module loader do weird things if that's what you really want; but that's not what you want, trust me. Just stick to the convention, like the other 99.9999999% of Perl applications do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With