Installing a ‘stubborn’ Perl Mod that is not recognised in @inc: HTTP::BrowserDetect

Posted by on Jan 21 2020, in kraxn

I have an old ‘beater’ laptop which I use to try Perl scripts among other things. I had just installed a very cool mod called HTTP::BrowserDetect. After installing it, I ran this to check and see if was installed:

perldoc -l HTTP::BrowserDetect 

Looks good, is installed. However when I ran the script, it was an internal server error. So I used tail

tail /var/log/apache2/error.log [pid 25664] Can't locate HTTP/ in @INC 
(you may need to install the HTTP::BrowserDetect module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 
/usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 
/usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 
/usr/share/perl/5.26 /usr/local/lib/site_perl /etc/apache2) at 
/var/www/testwebsite/public_html/ line 9.
nBEGIN failed--compilation aborted at /var/www/testwebsite/public_html/ line 9.n

Notice that it didn’t find “/home/myusername/perl5/lib/perl5/HTTP/” from my previous command. During the install, it probably recognised wisely that the Perl is used by my OS, and installed BrowserDetect in my home directory instead. How to fix?

In my perl script, I placed this line to the folder, at the top with my other ‘use’ lines. This worked! I am sure there are better ways, but this seemed simple and functional:

use lib qw(/home/myusername/perl5/lib/perl5/);