in reply to Re^3: Changing Module Tree
in thread Changing Module Tree

Alright, I tried to modify the test script, but I've discovered that with this code the "b" tree is never loaded.

#!/usr/bin/perl use Foo; for my $tree ("a","b") { local $ENV{PERL5LIB} = $tree; delete $INC{'Foo.pm'}; require Foo; Foo::Bar(); } Foo::Bar();

A side note, PERL5LIB is set to "a" when the script is executed.

Replies are listed 'Best First'.
Re^5: Changing Module Tree
by Anonymous Monk on Apr 06, 2011 at 14:44 UTC
    PERLLIB/PERL5LIB does not affect a running perl process

    $ perl -le "print for @INC
    C:/perl/site/5.12.2/lib/MSWin32-x86-multi-thread
    C:/perl/site/5.12.2/lib
    C:/perl/5.12.2/lib/MSWin32-x86-multi-thread
    C:/perl/5.12.2/lib
    .
     
    $ set PERL5LIB=blah
     
    $ perl -le "print for @INC
    blah
    C:/perl/site/5.12.2/lib/MSWin32-x86-multi-thread
    C:/perl/site/5.12.2/lib
    C:/perl/5.12.2/lib/MSWin32-x86-multi-thread
    C:/perl/5.12.2/lib
    .

    You want to manipulate @INC directly

Re^5: Changing Module Tree
by wind (Priest) on Apr 06, 2011 at 22:50 UTC
    use lib
    #!/usr/bin/perl require lib; for my $tree ("a","b") { lib->import($tree); delete $INC{'Foo.pm'}; require Foo; Foo::Bar(); lib->unimport($tree); }