List all installed perl modules from the command line


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

In the above example (which is all on one line),

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).