Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Question: Question: Is there any quick way to check the installed Perl modules from Linux/Unix command line.

Neel
4148 days ago

Question: Is there any quick way to check the installed Perl modules from Linux/Unix command line.

We always need to keep track of all the Perl modules, and install new one if required. Generally, whenever we run the Perl script it flash error message with the name of module not installed. I would like to know the quicker way to check the installed modules on any system/server.

Answers
2

You can try this:

perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'

In above Perl Oneliner

File::Find and File::Spec::Functions module are used to list all installed modules.
-M option loads the module. It executes use module before executing the script
-T option enables taint checking, which instructs perl to keep track of data from the user and avoid doing anything insecure with it. Here this option is used to avoid taking the current directory name from the @INC variable and listing the available .pm files from the directory recursively.
-l option enables automatic line-ending processing in the output. Print statements will have the new line separator (\n) added at the end of each line.
-w option prints any warning messages.
-e option indicates that the following string is to be interpreted as a perl script (i.e., sequence of commands).

Hope this will help.

0

Hey !! There is a Perl module ExtUtils::Installed for this kind of job. You should install it from cpan.

my $Inst = ExtUtils::Installed->new();
my @Modules = $Inst->modules();
print "Current List of Installed PERL Modules:\n\n";
foreach my $modName(@Modules){
print "$modName\n";
}

Cheers

0

Hi Neelam, 
If you would like to just check the specific module installed in your system, try this

perl -M<Module_name> -le 'print 1'

For example : To check Regexp::Common

perl -MRegexp::Common -le 'print 1'

If you get “1″ as the output, then the specified perl module is installed. If not, you’ll get the error message.

Cheers