Wednesday 20 August 2014

Perl @INC

Perl uses @INC array containing directory names to determine where to search for Perl module files.

To see the @inc paths; perl -e 'print join "\n", @INC'

To list/check all the Perl installed modules, enter the below given command:


find `perl -e 'print "@INC"'` -name '*.pm' -print

Tuesday 19 August 2014

Multiple Perl CPAN on a single machine

Hi Guys,

So you have multiple perl installed on a singlr machine at different locations. And the dilemma is- how to install perl modules for a specific Perl installation.

Say, I have Perl installed at the following location.

/custom/perl/5.8.9/ & /custom/perl/5.10

Now I want to install some Perl modules for Perl 5.10. How should I go ahead???

The solution is straightforward ( and very easy too :) )

Just follow the below given steps.

(1) Navigate to the cpan

/custom/perl/5.10/bin/cpan

(2) Now just install tha module you want.

install Error ( Error is a perl module)

Hey! its done Guys... Enjoy

Monday 18 August 2014

Perl installation on Linux

Perl installation on Linux/Unix

Lets install Perl in an easy way. Go through the below given steps to install Perl on Linux/Unix platforms.

(1) Download Perl using the URL provided below.

wget http://www.cpan.org/src/5.0/perl-5.8.9.tar.gz

(2) Now, we need to extract the download tar.gz file

 tar -xzf perl-5.8.9.tar.gz

(3) Once its done, just move( cd..) into the extracted file

cd perl-5.8.9

(4) Now the actual installation part starts.

./Configure -des -Dprefix=<path_to_perl_install_dir> -Dotherlibdirs=<default_path_to_search_for_perl_modules> -A ccflags=-fPIC

here the flag '-Dotherlibdirs' is used to set the path from where the perl will pick its modules. Below is the official documentation

otherlibdirs
This variable contains a colon-separated list of additional directories to add to @INC. By default, it will be empty. Perl will search these directories (including architecture and version-specific subdirectories) for add-on modules and extensions.
For example, if you have a bundle of perl libraries from a previous installation, perhaps in a strange place:
        Configure -Dotherlibdirs=/usr/lib/perl5/site_perl/5.8.9
(5) Now its the time to 'make'. Lets do it.

make && make install

(6) And its done. Yes, we have installed perl...Yahoo

One final thing, copy the perl installable file to /usr/bin ( for getting perl into system default path).

cp <path_to_perl_install_dir>/bin/perl /usr/bin/perl.

 Now, lets check our Perl installation.

perl -V

The above command will provide Perl version as well as the other important information.

So, we are done now. See, how easy it is.