in reply to use lib between modules

Presumably, you've done a use lib qw( /(lib path)/dirAAA ); somewhere prior to running the code in ModuleA, otherwise you wouldn't have gotten there.

One, somewhat hackish, solution is to inspect @INC.

BEGIN { my $lib_to_use; foreach my $dir (@INC) { $lib_to_use = $dir, last if $dir =~ m!dirAAA/?$!; }; $lib_to_use =~ s!dirAAA!dirBBB!; use lib $lib_to_use; } use ModuleB;

I'm sure there's a module that does this, but I'm too lazy to look for it.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^2: use lib between modules
by Anonymous Monk on Feb 15, 2005 at 15:38 UTC
    Thanks dragonchild and Tanktalus.
    First, I'm relieved that I wasn't overlooking something obvious. Second, I'm surprised that there isn't a more straightforward way of doing this. But maybe that's not a bad thing. As you both pointed out, it's probably better if all the application specific modules reside in the same directory, if possible. Thanks again!
    -David