Search My Techie Guy

Wednesday, November 19, 2014

One line script to list all the perl modules already installed on your server

Just copy and paste the command below into your command prompt:

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

If used with grep, you can easily search through the list to confirm if your already have a certain perl module installed on your server or not! for example am looking for a Perl module named "Time::HiRes", so i run the command below:

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

/usr/lib64/perl5/Time/Piece.pm
/usr/lib64/perl5/Time/HiRes.pm
/usr/lib64/perl5/Time/Seconds.pm
/usr/share/perl5/Net/Time.pm
/usr/share/perl5/CPAN/FirstTime.pm
/usr/share/perl5/Time/Local.pm
/usr/share/perl5/Time/tm.pm
/usr/share/perl5/Time/localtime.pm
/usr/share/perl5/Time/gmtime.pm

No comments: