When using Linux or UNIX, Perl is a very useful scripting language. There are many introductions on Perl module installation on the Internet. On the one hand, you can install it using software installation tools provided by different kits, on the other hand, you can install it through CPAN, and on the other hand, you can directly compile the source code.
In this way, for users with root permissions, there is no problem, but for general users who do not have root permissions, if you want to install and use the Perl module in your home directory, there are many other special features. Here I will introduce how to install and use the Perl module in the home directory of a common user.
Compilation and installation module:
Generally, there are several basic steps:
% Perl makefile. pl
% Make
% Make test
% Make install
% Make clean
Unlike installation with root permissions, users mustStep 1Specify the target path of the installation module with proper permissions.
For example, Perl makefile. pl -- prefix =/home/username/usr
Let your script find the module you have installed
After you install the module under/home/username/usrProgramYesUse these modulesYou can achieve this in two ways:
Use lib QW (/home/username/usr/lib/perl5/home/username/usr/lib/perl5/site_perl );
Or begin {unshift @ INC, QW (/usr/home/username/usr/local/lib/perl5/usr/home/username/usr/local/lib/perl5/site_perl );}
The principle is that the path of the Perl search module is stored in the @ INC array. You only need to add the custom module path to the array.
Set the search path for the Perl module outside the Perl script
If you need to set a search path for the Perl module outside the Perl script (for example, to solve the dependency between the installation module), you can useSet Environment Variables. The method is as follows:
Export perl5lib = \
/Home/<username>/usr/lib/
/Home/<username>/usr/lib/perl5/site_perl
Of course, if you put it in. bashrc, this setting can be laterIt works every time you log on to the system..