http://www.perlmonks.org?node_id=665190


in reply to Understanding module structure and inheritance

Just to add some notes....

I hope you're not confused between package main and Main. The former is automatically provided by Perl and each Perl program are implicitly in a package main. The later is normal user-defined package name.

Package Main::Contact indicates nothing about inheritance between Main and Contact, the double colon ("::") notation indicates physical structure where Main is the directory under which the file Contact.pm is located (it doesn't mean though that Main.pm doesnt exist).

About the layout.... I get used to put my private Perl modules under directory lib as found in CPAN module distributions (e.g. CGI-Application-x.yy/lib/CGI/Application.pm). You may also use lib/perl as seen in the standard Perl module directories layout by the system (e.g /usr/lib/perl or /usr/lib/perl5). If there are more sibling directories (as in my case), they are all under single directory (e.g. myappl) so later I can say,

use lib '/path/to/myappl/lib'; # or #use lib '/path/to/myappl/lib/perl'; # whichever the case
to let Perl knows where to search for my private modules.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!