I'm really confused and frustrated about how to get my PERL5LIB environment variable set correctly.
I'm on MacOS Sequoia, aarch64, running zsh, installed Perl 5.40.1 from source, into the /opt/perl_5.40.1 directory.
I already have a Perl 5.38.2, also built from source, located in the /opt/perl directory.
I have a MacPorts version of Perl installed (5.34.3). I removed an additional MacPorts Perl version 5.38.3 that I had installed recently.
I was reading in the Programming Perl book about PERL5LIB...I don't understand the order of the paths that should be in the PERL5LIB.
I've installed MANY Perl modules from CPAN using cpanm, specifying -L path respective to each version of Perl.
I have a section in my ~/.zshrc for Perl that looks like this:
use_perl_534() {
export PATH="/opt/local/bin:$PATH"
# export PERL5LIB="/opt/local/lib/perl5/5.34/site_perl:/opt/local/lib
+/perl5/5.34/lib:$PERL5LIB"
PERL5LIB="/opt/local/lib/perl5:/opt/local/lib/perl5/5.34:/opt/local/
+lib/perl5/5.34/darwin-thread-multi-2level:/opt/local/lib/perl5/vendor
+_perl/5.34:/opt/local/lib/perl5/vendor_perl/5.34/darwin-thread-multi-
+2level:$PERL5LIB"
echo "Using Perl 5.34"
}
# /opt/perl/lib/perl5/darwin-2level/ntheory.pm
# /opt/perl/lib/lib/perl5/darwin-2level/ntheory.pm
use_perl_538() {
export PATH="/opt/perl/bin:$PATH"
# export PERL5LIB="/opt/local/lib/perl5/5.38/site_perl:/opt/local/lib
+/perl5/5.38/lib:$PERL5LIB"
PERL5LIB="/opt/perl/lib/perl5:/opt/perl/lib/perl5/darwin-2level:/opt
+/perl/lib/perl5/darwin-2level/.meta:/opt/perl/lib/5.38.2:/opt/perl/li
+b/5.38.2/darwin-2level:/opt/perl/lib/site_perl/5.38.2:/opt/perl/lib/s
+ite_perl/5.38.2/darwin-2level:/opt/perl/lib/lib:/opt/perl/lib/lib/per
+l5:/opt/perl/lib/lib/perl5/darwin-2level:/opt/perl/lib/lib/perl5/darw
+in-2level/.meta:$PERL5LIB"
echo "Using Perl 5.38"
}
# /opt/perl_5.40.1/lib/lib/perl5/local
# /opt/perl_5.40.1/lib/lib/perl5/darwin-thread-multi-2level/auto/local
use_perl_540() {
export PATH="/opt/perl_5.40.1/bin:$PATH"
# export PERL5LIB="/opt/perl_5.40.1/lib/perl5/site_perl:/opt/perl_5.4
+0.1/lib/perl5:$PERL5LIB"
PERL5LIB="/opt/perl_5.40.1/lib:/opt/perl_5.40.1/lib/5.40.1:/opt/perl
+_5.40.1/lib/5.40.1/darwin-2level:/opt/perl_5.40.1/lib/site_p
erl:/opt/perl_5.40.1/lib/site_perl/5.40.1:/opt/perl_5.40.1/lib/site_pe
+rl/5.40.1/darwin-2level:/opt/perl_5.40.1/lib/lib:/opt/perl_5
.40.1/lib/lib/perl5:/opt/perl_5.40.1/lib/lib/perl5/darwin-thread-multi
+-2level:/opt/perl_5.40.1/lib/lib/perl5/darwin-thread-multi-2
level/.meta:$PERL5LIB"
echo "Using Perl 5.40.1"
}
I'm not using homebrew and I'm not using perlbrew.
I was using Sidef (installing manually as a standalone executable, not as a Perl Module) for some while, then things went bonkers when I installed Perl 5.38.3 from MacPorts (I think). Now Sidef fails, and many Perl programs fail that require modules (some work, some fail).
./wagstaff_primes.pl
Can't locate local/lib.pm in @INC (you may need to install the local::
+lib module) (@INC entries checked: /opt/perl_5.40.1/lib/site_perl/5.4
+0.1/darwin-2level /opt/perl_5.40.1/lib/site_perl/5.40.1 /opt/perl_5.4
+0.1/lib/5.40.1/darwin-2level /opt/perl_5.40.1/lib/5.40.1) at ./wagsta
+ff_primes.pl line 4.
BEGIN failed--compilation aborted at ./wagstaff_primes.pl line 4.
The aforementioned is a script from Rosetta Code.
find /opt/perl_5.40.1/lib -type f -name lib.pm
/opt/perl_5.40.1/lib/5.40.1/darwin-2level/lib.pm
/opt/perl_5.40.1/lib/lib/perl5/local/lib.pm