Search your unanswered perl queries
Google

Tuesday, November 13, 2007

One Liner : To check if a module is already installed

I have always came at this stop where i needed to check if a module is already installed or if so what is the version of the module.

perl -e "use [modulename]" e.g perl -e "use Net::SSH::Perl" will tell you if the module is installed or not. If its installed nothing happens and you get the prompt to perform new task. If it is not installed perl throws an error somewhat like can't locate Net/SSH/Perl.pm

perl -M[modulename] -e "print $[modulename]::VERSION" will print the current version of the module. e.g perl -MCGI -e "print $CGI::VERSION"
Most of the packages has a package variable as VERSION which holds the version of the module.

However the only true way to determine if a module is correctly installed, one can run the test scripts provided in the t folder of the module distribution. If all the scripts can run successfully, then only one can be sure that a particular module is installed fully or properly.

Do let us know what method do you use to see if a perl module is installed on your machine.

1 comment:

Dino said...

how to check it if a perl module is loaded or not through program