in reply to use lib between modules

In my ideal world, I'd have /(lib path) in the lib already, and then use dirAAA::ModuleA and dirBBB::ModuleB.

Assuming, however, that you're really using "use ModuleA" to get at ModuleA, you can use %INC:

my $libpath; BEGIN { ($libpath = $INC{'ModuleA.pm'}) =~ s:/dirAAA/.*:dirBBB:; } use lib $libpath;