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

joe picture joe · Jun 24, 2009 · Viewed 177.3k times · Source

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?

Answer

Alan Haggai Alavi picture Alan Haggai Alavi · Jun 24, 2009

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.