Tuesday, February 21, 2012

How to use the new Modern PERL features

I have PERL 5.8.8 installed on my system and I was trying to use some of the modern PERL features like "say". Of course, I wasn't able to do so. In order to access the features, the first step was to update PERL to a 5.10 or greater version. I installed the latest release available at the time - 5.14.2. I installed this version manually because I read on various sites that it is not advisable to remove the older version of PERL. Mainly because there are a lot of  packages that rely on PERL and you will need to delete all these packages to remove PERL using yum remove perl or any other tool. So, it is just easier to have both the versions. To prevent YUM from modifying your current version, you can type the following in /etc/yum.conf: exclude=perl

Here are the upgrade steps that I took manually:

- wget http://search.cpan.org/CPAN/authors/id/F/FL/FLORA/perl-5.14.2.tar.gz
- tar -xzvf  perl-5.14.2.tar.gz
- cd /home/user/perl-5.14.2/
     - sh Configure -de Dusethreads : The option "Dusethreads" is to compile the interpreter to support threads.  
     - make
     - make test -> All of them didn't pass but >80% tests passed.
     - make install -> this needs to be run as root.
- Now, /usr/local/bin/perl was on 5.14.2 whereas /usr/bin/perl was still on 5.8.8. I didn't care about it because I used "use feature ':5.10' " in my perl scripts to enable the newer version features but if you care then do the following:
      - mv /usr/bin/perl /usr/bin/perl_5_8_8
      - ln -s /usr/local/bin/perl /usr/bin/perl

Wednesday, February 8, 2012

How to find what PERL modules are installed on my system



1. The easiest way of doing so is by running the command intstmodsh. It provides an interactive interface to query details of installed PERL modules. When you run instmodsh, this is what you get:

At the prompt you can enter 'l' to list all the installed modules.

2. Another way to do this is:
perldoc perllocal


This command will list out all the installed modules along with their path and version information.

3. Yet another way of getting all the modules installed on your system along with the path information, type:
find `perl -e 'print "@INC"' ` -name '*.pm' -print



4. perl -le 'eval "require DBI" and print ${"DBI::VERSION"}'


5. find `perl -e '{print join $/, grep {/[^.]/} @INC}'` -name '*pm'|grep DBI|more


6. perl -MDBI -e'print $_ . " => " . $INC{$_} . "\n" for keys %INC'