Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if a Perl module is installed on my system from the command line?

I tried to check if XML::Simple is installed in my system or not.

perl -e 'while (<@INC>) { while (<$_/*.pm>) { print "$_\n"; } }'

The above one-liner was used for listing all modules installed in my system. However, it is not listing XML modules.

However, the following executes fine.

perl -e "use XML::Simple "

What might be the issue?

like image 599
joe Avatar asked Jun 24 '09 15:06

joe


People also ask

How do I check if a perl module is installed?

Check installed perl modules via terminal Available commands are: l - List all installed modules m <module> - Select a module q - Quit the program cmd? Then type l to list all the installed modules, you can also use command m <module> to select the module and get its information. After finish, just type q to quit.

How do you check which version of perl is installed on a system from the command line?

Type perl -v on a command line to find out which version. ActiveState Perl has binary distributions of Perl for many platforms. This is the simplest way to install the latest version of Perl.

How do I know if perl DBI module is installed on Linux?

If the module is not installed, then: $ perl -e 'use dbi' Can't locate dbi.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14. 2 /usr/local/share/perl/5.14. 2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .)


2 Answers

You can check for a module's installation path by:

perldoc -l XML::Simple

The problem with your one-liner is that, it is not recursively traversing directories/sub-directories. Hence, you get only pragmatic module names as output.

like image 157
Alan Haggai Alavi Avatar answered Oct 28 '22 23:10

Alan Haggai Alavi


Quick and dirty:

$ perl -MXML::Simple -e 1
like image 22
Sinan Ünür Avatar answered Oct 29 '22 00:10

Sinan Ünür