Search code examples
perlcpan

Installing local module + submodules using cpanp


I have the following project structure:

A/
|- B.pm
|- B/
 |- one.pm
 |- two.pm
 |- three.pm

in B.pm I have:

package A::B;

use A::B::one;
use A::B::two;
use A::B::three;

Now, I'm trying to install this module locally using cpanp. When in the A directory I simply run:

cpanp i .

It says Module 'A' installed successfully, however, when I list the content of my $PERL5LIB directory, all I can see is B.pm instead of A/.

What am I doing wrong?


Solution

  • This is probably not the recommended way to do it but for those looking for a quick-and-dirty solution, just move everything to a lib directory.

    For me it looks like:

    A-B
    └── lib
        └── A
            ├── B
            │   ├── one.pm
            │   ├── three.pm
            │   └── two.pm
            └── B.pm
    

    When in the A-B directory, I simply run:

    cpan .
    

    As I just want to install my module locally this approach worked for me but let me know if you think there are good reasons to use tools like module-starter (as suggested by @HåkonHægland) or at least write my own Makefile.PL (which is actually the approach I ended up with as I wanted to list dependencies).