[Mpls-pm] System-context referencing of in-house perl libraries
Ken Williams
ken at mathforum.org
Wed Feb 8 20:06:24 PST 2006
On Feb 7, 2006, at 4:16 PM, Shane McCarron wrote:
> You can put your use lib statements in a BEGIN block... so you can do
> something like
>
> BEGIN {
>
> if ($^O eq "MSWin32") {
> use lib whatever...
> } else {
> use lib unixy things
> }
>
> }
That won't work, actually, because 'use' is a compile-time directive
and not sensitive to being inside an if(). Watch this:
% perl -le 'if ($x) { use lib "/foo" } else { use lib "/bar" }; print
for @INC'
/bar
/foo
/sw/lib/perl5/5.8.1/darwin-thread-multi-2level
/sw/lib/perl5/5.8.1
/sw/lib/perl5
...
Personally I'd probably just put all the libs in for good measure, they
don't really hurt anything:
use lib "/usr/local/bass/lib";
use lib "/usr/local/bass/alder/lib";
use lib 'c:\Program Files\bass\<libraries>';
But if you don't want to do that, you could use a solution like Josh's,
or you could externalize it altogether and make the *caller* specify
where the libs live, either through setting the PERL5LIB environment
variable or using the -I switch or whatever.
-Ken
More information about the Mpls-pm
mailing list