in reply to How can you make 'use lib "foo"; dynamic?
Maybe I'm misunderstanding what you're asking, but as long as you include the use lib in program that uses the modules in question, you don't need to include it in any of these modules/classes. (Example below.)
In the following example, Foo.pm lives in /tmp/foobar, Bar.pm and my_script.pl live in the current directory, and Bar inherits from Foo. Not that neither Foo.pm nor Bar.pm make reference to any directory.
# /tmp/foobar/Foo.pm package Foo; !! 'keep require happy'; sub baz { print 'Hello from ' . shift() . '::baz' . "\n"; } __END__
# ./Bar.pm package Bar; use base 'Foo'; !! 'keep require happy'; __END__
# ./my_script.pl use lib '/tmp/foobar'; use Bar; Bar->baz(); __END__
% perl my_script.pl Hello from Bar::baz
In fact, I can even omit the use lib line from my_script.pl, by invoking it with
or% perl -I/tmp/foobar my_script.pl
% perl -Mlib=/tmp/foobar my_script.pl
the lowliest monk
|
|---|