Perl redirects to wrong execution path - perl

I am facing some problem with Perl. During execution, I am getting this error.
Can't locate XML/LibXML/NodeList.pm in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/lib64/perl5/XML/LibXML.pm line 25.
But when I tried to find this file using locate command i found it under.
/usr/local/lib/perl5/site_perl/5.18.0/x86_64-linux/XML/LibXML/ directory.
I have installed different perl packages and they are all installed correctly. If I put single file at specified location then it will complain about another file. So putting file manually is not an good idea.
So how do i change its path to so it can execute the files from correct directory?
Edit
Can't locate loadable object for module XML::LibXML in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/lib64/perl5/XML/LibXML.pm line 154
[Wed Jul 03 10:15:13 2013] [error] [client 192.73.242.136] BEGIN failed--compilation aborted at /usr/local/lib64/perl5/XML/LibXML.pm line 154.
[Wed Jul 03 10:15:13 2013] [error] [client 192.73.242.136] Compilation failed in require at /var/www/cgi-bin/astpp/astpp-cdr-xml.cgi line 23.
[Wed Jul 03 10:15:13 2013] [error] [client 192.73.242.136] BEGIN failed--compilation aborted at /var/www/cgi-bin/astpp/astpp-cdr-xml.cgi line 23.
[Wed Jul 03 10:15:13 2013] [error] [client 192.73.242.136] Premature end of script headers: astpp-cdr-xml.cgi

The instance of XML::LibXML that you have found probably belongs to a different installation of perl. It may not work even if you extend the search path to include its location.
You should install the library afresh, using whatever tool is appropriate - probably cpan.

I agree with Borodin. It appears that your Perl installation maybe different from the standard Perl already installed on the system.
What happens if you type in:
$ which perl
or
$ type perl
One of these two commands should show you which Perl program is being executed by default.
What Perl executable does the first line of your Perl program point to? (It looks something like #! /usr/bin/perl Are they two different locations?
What happens when you type in perl -V which should list all of the standard locations of where your Perl modules may be installed?
It is also possible that your installation of the XML::LibXML module is bad. I think the directory you see is for the binary program that XML::LibXML depends upon, but there should also be a Perl version that will refer to that binary somewhere like usr/local/lib/perl5/site_perl/5.18.0/XML/LibXML/.
Try reinstalling this module with CPAN and afterwards, run the following command:
$ perldoc -l XML::LibXML::Nodelist
and see where it was installed.

Related

Can't locate Text/Soundex.pm in #INC

I was installing repeatsmasker and it apparently seems to work because it shows "Congratulations! RepeatMasker is now ready to use."
But when I run it it reports "Can't locate Text/Soundex.pm...". so I installed the module by "sudo cpan Text::Soundex", and by the end it tells me "Text::Soundex is up to date (3.05)." It seems the module is already installed, but RepeatMasker still has the same problem, as I'll show you in this code:
fragua#picci:~/RM/RepeatMasker$ sudo cpan Text::Soundex
Loading internal null logger. Install Log::Log4perl for logging messages
Reading '/home/fragua/.cpan/Metadata'
Database was generated on Fri, 19 Apr 2019 22:17:03 GMT
Text::Soundex is up to date (3.05).
fragua#picci:~/RM/RepeatMasker$ ./RepeatMasker -s -lib /home/fragua/RepeatScout-1.0.5/ObiINK5k_repeats_filtered1.fasta /home/fragua/Documenti/Workdirectory/ObiINC5k.fa
Can't locate Text/Soundex.pm in #INC (you may need to install the Text::Soundex module) (#INC contains: /home/fragua/RM/RepeatMasker /home/fragua/perl5/lib/perl5 /home/fragua/anaconda/lib/site_perl/5.26.2/x86_64-linux-thread-multi /home/fragua/anaconda/lib/site_perl/5.26.2 /home/fragua/anaconda/lib/5.26.2/x86_64-linux-thread-multi /home/fragua/anaconda/lib/5.26.2 .) at /home/fragua/RM/RepeatMasker/Taxonomy.pm line 80.
BEGIN failed--compilation aborted at /home/fragua/RM/RepeatMasker/Taxonomy.pm line 80.
Compilation failed in require at ./RepeatMasker line 310.
BEGIN failed--compilation aborted at ./RepeatMasker line 310.
I installed RepeatMasker in another computer without problems, but I don't know why now I encontered this problem
You have two builds of Perl installed:
/usr/bin/perl
/home/fragua/anaconda/bin/perl.
/home/fragua/anaconda/bin/perl is first in your PATH. This means that programs with the following shebang (#!) line will use /home/fragua/anaconda/bin/perl:
#!/usr/bin/env perl
RepeatMasker appears to be such a program.
All of this is fine.
The Problem
/home/fragua/anaconda/bin contains the scripts installed by /home/fragua/anaconda/bin/perl. As part of the installation process of these scripts, the shebang line of these scripts should have been rewritten to specify /home/fragua/anaconda/bin/perl.
However, the shebang line of /home/fragua/anaconda/bin/cpan references /usr/bin/perl. This means that using /home/fragua/anaconda/bin/cpan would install modules for /usr/bin/perl, not /home/fragua/anaconda/bin/perl.
The Workaround
You could avoid relying on the shebang line and explicitly specify the correct perl.
/home/fragua/anaconda/bin/perl /home/fragua/anaconda/bin/cpan Text::Soundex
Or, given your $PATH,
perl /home/fragua/anaconda/bin/cpan Text::Soundex
The Fix
To fix this problem in an ongoing manner requires changing the shebang lines of the scripts to be what they should be. In every file in /home/fragua/anaconda/bin (and in particular for cpan), replace
#!/usr/bin/perl
with
#!/home/fragua/anaconda/bin/perl
You could do this use the following (which does a backup of the files it changes):
perl -0777ne'print "$ARGV\n" if m{^#!\s*/usr/bin/perl\b}' /home/fragua/anaconda/bin/* \
| xargs perl -i~ -0777pe's{^#!\s*/usr/bin/perl\b}{#!/home/fragua/anaconda/bin/perl}'

cpan command gives the error "Can't locate B.pm in #INC"

I wanted to use CPAN to install some Perl packages, but I get the following error when I try to start the CPAN shell:
paulzierep#naproxen:~$ cpan
Can't locate B.pm in #INC (you may need to install the B module) (#INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base /home/paulzierep) at /usr/share/perl/5.22/Safe.pm line 34.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/Safe.pm line 34.
Compilation failed in require at /usr/share/perl/5.22/CPAN.pm line 56.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/CPAN.pm line 56.
Compilation failed in require at /usr/share/perl/5.22/App/Cpan.pm line 273.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/App/Cpan.pm line 273.
Compilation failed in require at /usr/bin/cpan line 9.
BEGIN failed--compilation aborted at /usr/bin/cpan line 9.
I can't figure out how to install the missing B module without cpan. I guess this should be installed by default.
I'm using Perl 5.22.1 on Ubuntu 16.04.
Update
So I set the PERL5LIB or PERL5OPT to make it find /usr/lib/x86_64-linux-gnu/perl/5.22.1/B.pm, and CPAN runs, but I can not install anything due to the following error
cpan[1]> install Log::Log4perl
Reading '/home/paulzierep/.cpan/Metadata'
Database was generated on Fri, 30 Sep 2016 06:29:02 GMT
Running install for module 'Log::Log4perl'
Checksum for /home/paulzierep/.cpan/sources/authors/id/M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz ok
Scanning cache /home/paulzierep/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Have /usr/lib/x86_64-linux-gnu/perl/5.22.1
Want /usr/lib/x86_64-linux-gnu/perl/5.22
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [5.22.1]
Config says: [x86_64-linux-gnu-thread-multi]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Generating a Unix-style Makefile
Writing Makefile for Log::Log4perl
Writing MYMETA.yml and MYMETA.json
MSCHILLI/Log-Log4perl-1.47.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz
make: *** No rule to make target '/usr/lib/x86_64-linux-gnu/perl/5.22/Config.pm', needed by 'Makefile'. Stop.
MSCHILLI/Log-Log4perl-1.47.tar.gz
/usr/bin/make -- NOT OK
Failed during this command:
MSCHILLI/Log-Log4perl-1.47.tar.gz : make NO
So it kind of fixed it and left me with another problem. Any help on this one?
That what I get for:
paulzierep#naproxen:~$ perl -E 'say for #INC'
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
.
paulzierep#naproxen:/home$ perl -MFile::Spec -E 'say for
File::Spec->path'
/home/paulzierep/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
I had the same problem. For some unknown reason, the directory /usr/lib/x86_64-linux-gnu/perl was empty. My solution was to reinstall the libperl5.22 package.
sudo apt-get install --reinstall libperl5.22
So after having a look on a different systems with pretty similar set-up I found whats the problem with my perl install. It always bugged me, that the 5.22 folder is empty, but still seems to be the folder perl is looking for.
paulzierep#naproxen:/usr/lib/x86_64-linux-gnu/perl$ ls
5.22 5.22.1 cross-config-5.22.1 debian-config-data-5.22.1
In a system with similar set-up I found that the 5.22 was linking to 5.22.1, setting this link solved the problem and perl runs again like a charm.
I additional wanted to point out, that in my reseach I found that the working directory "." seems to be in #INC by default, (http://www.perlmonks.org/bare/?node_id=375341) therefore I am wondering why it seems so strange to some (#Borodin), that my home directory is there (Any directory is there as long as you start cpan from there).
Also I don't see how perlbrew would help here, besides the fact, that you cannot install it without working perl, I don't see how it would help, when your system perl does not work properly.
$ cpan
Can't locate File/Spec.pm: /usr/local/lib/x86_64-linux-gnu/perl/5.22.1/File/Spec.pm: Permission denied at /usr/share/perl/5.22/CPAN.pm line 10.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/CPAN.pm line 10.
Compilation failed in require at /usr/share/perl/5.22/App/Cpan.pm line 273.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/App/Cpan.pm line 273.
Compilation failed in require at /usr/bin/cpan line 9.
BEGIN failed--compilation aborted at /usr/bin/cpan line 9.
Perl don't looking modules in #INC.

Perl modules not loading correctly when running as non-root user

I'm running into an issue with Perl on a linux system.
When installing new modules (as root), I would occasionally have issues where running scripts as a regular user, I would not be able to access the new module without manually going in and chmod 775'ing the module related files and directories.
I recently performed a CPAN upgrade, as well as installing several modules for a new project. Now, Perl has become almost unusable as a regular user, because of errors that don't appear to be permissions related.
For example, the following very simple script runs fine as root, but returns an error run as a regular user:
#!/usr/bin/perl
use strict;
use warnings;
use Scalar::Util;
As you can see, the script literally does nothing except attempt to load the Scalar::Util module. As a regular user, it returns this error:
**List::Util object version 1.21 does not match bootstrap parameter 1.42 at /usr/lib64/perl5/DynaLoader.pm line 223.
Compilation failed in require at /usr/local/lib64/perl5/Scalar/Util.pm line 22.
Compilation failed in require at ./scalar-test.pl line 4.
BEGIN failed--compilation aborted at ./scalar-test.pl line 4**
When I sudo cpan and try install List::Util, I get back:
List::Util is up to date (1.42).
CLARIFICATION: This is happening with several modules, not just the one example. It does not appear to affect every module that was upgraded though; it's several though.
The fact that root can run the scripts says to me that either there is another, underlying permissions issue I'm not seeing, OR PERL is configured slightly different in some way for root than my regular account which is causing it not to find this module.
A search for the List.pm file is returning:
» sudo find / -name List.pm
/usr/share/perl5/I18N/LangTags/List.pm
/opt/OV/nonOV/perl/a/lib/5.8.8/I18N/LangTags/List.pm
/root/.cpan/build/perl-5.22.1-D0_eFO/dist/I18N-LangTags/lib/I18N/LangTags/List.pm
» ls -l /usr/share/perl5/I18N/LangTags/List.pm
-rw-r--r-- 1 root root 28826 Nov 6 2014 /usr/share/perl5/I18N/LangTags/List.pm
» ls -l /opt/OV/nonOV/perl/a/lib/5.8.8/I18N/LangTags/List.pm
-r--r--r-- 1 bin bin 28826 Nov 30 2012 /opt/OV/nonOV/perl/a/lib/5.8.8/I18N/LangTags/List.pm
» sudo ls -l /root/.cpan/build/perl-5.22.1-D0_eFO/dist/I18N-LangTags/lib/I18N/LangTags/List.pm
-r--r--r-- 1 1018 513 28826 Oct 17 08:32 /root/.cpan/build/perl-5.22.1-D0_eFO/dist/I18N-LangTags/lib/I18N/LangTags/List.pm
System is RHEL 6.6 x64, Perl is v5.10.1
**» type perl**
perl is hashed (/usr/bin/perl)
**» which perl**
/usr/bin/perl
**» sudo type perl**
sudo: type: command not found
**» sudo which perl**
/usr/bin/perl
**» echo ${!PERL*}**
[Nothing Returned]
**» sudo echo ${!PERL*}**
[Nothing Returned]
**» perl -wle 'print join("\n", #INC)'**
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
[run with sudo returns identical list]
[Edited for brevity]
cpan[1]> o conf
$CPAN::Config options from /usr/share/perl5/CPAN/Config.pm:
build_dir [/root/.cpan/build]
build_dir_reuse [0]
build_requires_install_policy [ask/yes]
connect_to_internet_ok [1]
cpan_home [/root/.cpan]
keep_source_where [/root/.cpan/sources]
make [/usr/bin/make]
make_install_make_command [/usr/bin/make]
makepl_arg [INSTALLDIRS=site]
prefer_installer [MB]
prefs_dir [/root/.cpan/prefs]
I redacted a few lines here from other user's folders
» sudo find / -name Util.pm | grep "List/Util.pm"
/usr/lib64/perl5/List/Util.pm
/usr/local/lib64/perl5/List/Util.pm
/home/{USERNAME REDACTED}/.cpanm/work/1448660183.31550/ExtUtils-MakeMaker-7.10/bundled/Scalar-List-Utils/List/Util.pm
/root/.cpan/build/Scalar-List-Utils-1.42-2c3ONp/lib/List/Util.pm
/root/.cpan/build/Scalar-List-Utils-1.42-2c3ONp/blib/lib/List/Util.pm
/root/.cpan/build/Scalar-List-Utils-1.42-NOwU0A/lib/List/Util.pm
/root/.cpan/build/Scalar-List-Utils-1.42-NOwU0A/blib/lib/List/Util.pm
/root/.cpan/build/perl-5.22.1-D0_eFO/cpan/Scalar-List-Utils/lib/List/Util.pm
Per request of brian d foy, I installed a new module. This module Config::Onion was not previously installed, so nothing old to conflict. The module installs OK, but I created an onion-test.pl script, same as above, and it has the same issue where it only loads the module as root.
» sudo perl -MConfig::Onion -e 'print "Module: " . $ARGV[0] . "\nVersion: " . $ARGV[0]->VERSION . "\n\n"' Config::Onion
Can't locate Config/Onion.pm in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.
» sudo cpan
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v2.10)
Enter 'h' for help.
cpan[1]> install Config::Onion
[Redacted for brevity. No errors noted during this process.]
Result: PASS
DSHEROH/Config-Onion-1.004.tar.gz
/usr/bin/make test -- OK
Running make install
Prepending /root/.cpan/build/Config-Onion-1.004-TigyuT/blib/arch /root/.cpan/build/Config-Onion-1.004-TigyuT/blib/lib to PERL5LIB for 'install'
Manifying 2 pod documents
Installing /usr/local/share/perl5/Config/Onion.pm
Installing /usr/local/share/perl5/Config/Onion/Simple.pm
Installing /usr/local/share/man/man3/Config::Onion.3pm
Installing /usr/local/share/man/man3/Config::Onion::Simple.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
DSHEROH/Config-Onion-1.004.tar.gz
/usr/bin/make install -- OK
» cd /usr/local/share/perl5/Config
» sudo ls -l Onion
total 4
-r--r--r-- 1 root root 1856 May 9 2014 Simple.pm
» sudo find / -name Onion.pm
/usr/local/share/perl5/Config/Onion.pm
/root/.cpan/build/Config-Onion-1.004-TigyuT/lib/Config/Onion.pm
/root/.cpan/build/Config-Onion-1.004-TigyuT/blib/lib/Config/Onion.pm
onion-test.pl:
#!/usr/bin/perl
use strict;
use warnings;
use Config::Onion;
» ./onion-test.pl
Can't locate Hash/Merge/Simple.pm in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/share/perl5/Config/Onion.pm line 9.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Config/Onion.pm line 9.
Compilation failed in require at ./onion-test.pl line 29.
BEGIN failed--compilation aborted at ./onion-test.pl line 29.
» sudo ./onion-test.pl
[No Errors]
Per Ikegami, I ran this command:
sudo chmod -R go+rX \
/usr/local/lib64/perl5 \
/usr/local/share/perl5 \
/usr/lib64/perl5/vendor_perl \
/usr/share/perl5/vendor_perl \
/usr/lib64/perl5 \
/usr/share/perl5
Both of my test scripts, with Scalar::Util and Config::Onion are loading the modules without error. I think his solution is the right one for the issue I was having, and I've marked it accordingly. Thanks everyone for your research, and to Ikegami for hitting on the solution.
List/Util/Util.so probably exists twice in
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
They are different versions. The newer one can only be accessed by root. If this is the problem it will be solved using
chmod -R go+rX \
/usr/local/lib64/perl5 \
/usr/local/share/perl5 \
/usr/lib64/perl5/vendor_perl \
/usr/share/perl5/vendor_perl \
/usr/lib64/perl5 \
/usr/share/perl5
I can only get so far on the information you provide, but here's a start. If you fill in some details we may be able to figure out this problem.
These sorts of error typically mean that you have two versions of the same module installed in different places or that the it was upgraded incompletely in one place (perhaps because someone tried it by hand, had insufficient permissions, or was interrupted). The program is able to load one part of the module from one source, fails to load a second part and looks elsewhere. Hence you get the mismatch.
In your case, it looks like you have List::Util in both /usr/lib64/perl5 and
/usr/local/lib64/perl5. From your #INC, you look in /usr/local/lib64/perl5 first. I'm guessing that's where the newest version should be. For some reason, it doesn't load right so it keeps looking and finds the old version in /usr/lib64/perl5, but that's a mismatch.
For pure Perl files, these matches don't usually matter. However, for the compiled (XS) modules, the details of their compilation have to match up. Different versions of the same compilation tools, or different inputs to the same versions, likely cause incompatible formats. Or, different versions of the same Perl module name might have been reorganized so they don't match up with the binary component of previous versions. Hence the error message you get after something else already went wrong.
I wonder in your case if you've set an odd umask so that your root module installation doesn't make the file readable (or the directory executable) so other users can see the files. What were the permissions before you changed them? You should track down that problem since you said you've had the same problem previously (and may again).
The cpan module can find it for you looking through the current Perl's #INC. I haven't upgraded List::Util on this version of Perl, and it's found under lib/5.22.0/darwin-2level:
$ cpan -D List::Util
CPAN: Storable loaded ok (v2.53)
Reading '/Users/brian/.cpan/Metadata'
Database was generated on Tue, 26 Jan 2016 12:17:02 GMT
List::Util
-------------------------------------------------------------------------
List utilities (eg min, max, reduce)
P/PE/PEVANS/Scalar-List-Utils-1.42.tar.gz
/usr/local/perls/perl-5.22.0/lib/5.22.0/darwin-2level/List/Util.pm
Installed: 1.41
CPAN: 1.42 Not up to date
Graham Barr (GBARR)
gbarr#pobox.com
After I update it, the update is in lib/site_perl/5.22.0/darwin-2level, a different directory. CPAN.pm does not remove old versions, it merely shadows them. I still have the version that originally came with your Perl, and now you have an update in site_perl
$ cpan -D List::Util
CPAN: Storable loaded ok (v2.53)
Reading '/Users/brian/.cpan/Metadata'
Database was generated on Tue, 26 Jan 2016 12:17:02 GMT
List::Util
-------------------------------------------------------------------------
CPAN: Module::CoreList loaded ok (v5.20150520)
List utilities (eg min, max, reduce)
P/PE/PEVANS/Scalar-List-Utils-1.42.tar.gz
/usr/local/perls/perl-5.22.0/lib/site_perl/5.22.0/darwin-2level/List/Util.pm
Installed: 1.42
CPAN: 1.42 up to date
Graham Barr (GBARR)
gbarr#pobox.com
The paths may vary from system to system, but the idea is the same. I have different versions in different directories.
Now to recreate the problem. Curiously, in Perl v5.22, when I move the newly installed directory so it doesn't have the right name (forcing Perl to look in the wrong directory), I get a much friendly (although similarly unhelpful) message:
$ perl5.22.0 -MScalar::Util -e 1
List::Util version 1.42 required--this is only version 1.41 at /usr/local/perls/perl-5.22.0/lib/site_perl/5.22.0/darwin-2level/Scalar/Util.pm line 23.
Compilation failed in require.
BEGIN failed--compilation aborted.
It looks like you are using Perl 5.8.8. When I tried this same process on my system, cpan wrote files to the same location.
However, you can configure cpan for the installation locations. Your system may have helpfully done that for you. If you have the build logs (or cpan config or package manager info) to show us where it installed the new List::Util, that could help. Or, find us the list of List/Util.pm files you have installed and we could work backward. If you installed from a package, that might have chosen another location.
My advice is normally to leave the base installation alone and install everything into a different set of directories. If you are playing with the system perl (and it looks like you are), messing up the same perl that system needs for its admin and housekeeping tasks can cause additional headaches.
For those, who struggle with this kind of issue, and are running grsec linux kernel, check dmesg -T for occurences of messages, such as
[Thu Jul 13 12:39:32 2017] grsec: From 12.34.56.78: denied untrusted exec (due to file in group-writable directory) of /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/auto/DBD/mysql/mysql.so by /usr/bin/perl[perl:9515] uid/euid:1000/1000 gid/egid:1000/1000, parent /bin/bash[bash:31545] uid/euid:1000/1000 gid/egid:1000/1000
This means non-root user was not able to use perl shared library mysql.so because of permissions on parent folder.
Solution good enough is to (for example, in this particular case) chmod parent folder g-w (group -write)
chmod g-w /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/auto/DBD/mysql/

Unable to load (and reinstall) Socket.pm after upgrade

I've just upgraded Slackware64 to 14.1 and I found Perl 5.18 in it. Socket.pm now complains that it was compiled for another Perl version, which was 5.16. Here is the error:
Perl API version v5.16.0 of Socket does not match v5.18.0 at /usr/share/perl5/XSLoader.pm line 92.
Unfortunately, I'm even unable to reinstall Socket.pm even with cpan.
$ cpan Socket
Reading '/home/francesco-salix/.cpan/Metadata'
Database was generated on Tue, 26 Nov 2013 09:08:12 GMT
Running install for module 'Socket'
Running make for P/PE/PEVANS/Socket-2.013.tar.gz
Checksum for /home/francesco-salix/.cpan/sources/authors/id/P/PE/PEVANS/Socket-2.013.tar.gz ok
CPAN.pm: Building P/PE/PEVANS/Socket-2.013.tar.gz
Attempt to reload Socket.pm aborted.
Compilation failed in require at /usr/share/perl5/IPC/Cmd.pm line 46.
BEGIN failed--compilation aborted at /usr/share/perl5/IPC/Cmd.pm line 46.
Compilation failed in require at /usr/share/perl5/ExtUtils/CBuilder/Base.pm line 11.
BEGIN failed--compilation aborted at /usr/share/perl5/ExtUtils/CBuilder/Base.pm line 11.
Compilation failed in require at /usr/share/perl5/ExtUtils/CBuilder/Platform/Unix.pm line 4.
BEGIN failed--compilation aborted at /usr/share/perl5/ExtUtils/CBuilder/Platform/Unix.pm line 4.
Compilation failed in require at (eval 6) line 2.
BEGIN failed--compilation aborted at (eval 6) line 2.
Compilation failed in require at Makefile.PL line 19.
Warning: No success on command[/usr/bin/perl5.18.1 Makefile.PL]
'YAML' not installed, will not store persistent state
PEVANS/Socket-2.013.tar.gz
/usr/bin/perl5.18.1 Makefile.PL -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Could not read metadata file. Falling back to other methods to determine prerequisites
As far as I've understood, Socket.pm is a Perl core module. So, I thought it would have been upgraded together with Perl.
Here are directories currently in #INC:
$ perl -E'say for #INC'
/home/francesco-salix/perl5/lib/perl5/x86_64-linux-thread-multi
/home/francesco-salix/perl5/lib/perl5
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
.
I see some folders seems duplicate, but I don't actually know if they are supposed to be like that. However, there's no Socket.pm in the first two path (which I assume where added by cpan while running under my user, while I've a Socket.pm file for both /usr/local/lib64/perl5/ and /usr/lib64/perl5.
Socket.pm is indeed a core module. And the CPAN.pm moduleExtUtils::MakeMaker uses it (via IPC::Cmd), so if Socket.pm is broken, CPAN.pmMakefile.PL will be broken too.
Given that it is a core module, and would have been installed with Perl, this suggests to me that Perl is trying to load Socket.pm from some other, older path. The following will tell you where Perl is trying to load modules from:
perl -E'say for #INC'
Is there anything suspicious in there. Any place it might find older modules compiled for Perl 5.16?
The solution is to clear the old modules, following 3rensho’s comment:
sudo rm -rf /usr/local/lib64/perl5/*
sudo rm -rf /usr/local/share/perl5/*
It works!

Custom Perl Modules on Apache2 Server

Currently I am trying to use a bunch of custom perl modules, test.pm as one of them, within my Perl program with a WebUI. I am running it on a Windows 7 machine with Apache2 installed. When I run the program in cmd prompt by using perl test.pl, the program runs fine. However running it on Apache gives me this error.
[Wed Jun 13 16:23:32 2012] [error] [client 127.0.0.1] Can't locate test.pm in #INC (#INC contains: C:/Perl/lib C:/Perl/site/lib .) at C:/www/hello2.pl line 7.\r, referer: http://localhost/ui_test.htm
[Wed Jun 13 16:23:32 2012] [error] [client 127.0.0.1] BEGIN failed--compilation aborted at C:/www/hello2.pl line 7.\r, referer: http://localhost/ui_test.htm
I have used:
foreach $key (sort keys(%ENV)) {
print "$key = $ENV{$key}<p> \n";
}
and under the path variable, I do see the folder of where all the modules are located. Is there somewhere else I should use to add to the Perl Path?
In addition adding use lib "C:\testpm\"; to my code only changes the #INC to
(#INC contains: C:\testpm\ C:/Perl/lib C:/Perl/site/lib .)
Is there something additional you need to do to add paths to run custom perl modules on an apache server?
Solution Based On Answer:
I found this to work the best. Within my httpd-perl.conf file, I added these lines:
<IfModule env_module>
SetEnv PERL5LIB "C:\testpm;C:\testpm1;"
</IfModule>
(extended out with C:\testpm1 to show people with similar questions how to add even more module folders.)
The PATH environment variable has no bearing on where perl will load modules from, that is #INC. You said your path is in #INC, but in the error message you show, it is not.
Can't locate test.pm in #INC (#INC contains: C:/Perl/lib C:/Perl/site/lib .) at
You should call use lib during server startup. See http://perl.apache.org/docs/2.0/user/handlers/server.html#Startup_File.
Also, try removing the trailing slash, eg use lib 'C:\testpm'.
use lib is good if you can add in setup file otherwise you will have to add it in every single perl script file.Rather than doing this, you can use PERL5LIB environment variable.
#INC in perl doesn't take value of PATH environment variable rather it can take from PERL5LIB environment variable.
You can add SetEnv PERL5LIB path_to_modules_directory directive in your apache configuration.Your perl script will add this path at front of original #INC value while executing your perl script.