in reply to Loading and using packages dynamically

The first problem roots in the fact that the assignment to $libDir is executed at run time, but use is evaluated at compile time.

One possible workaround is to do the assignement in a BEGIN block.

use Foo qw(bar baz); is replaceable by require Foo; Foo->import(qw(bar baz)); which solves the next problem.

You could also take a look at Module::Load.