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