Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it mandatory that a folder by the name of a package should be present for creating a package?

Tags:

package

perl

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).

like image 864
Liju Mathew Avatar asked Dec 23 '22 13:12

Liju Mathew


1 Answers

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.

like image 88
jrockway Avatar answered May 03 '23 03:05

jrockway