Wednesday, September 30, 2009

Display the list of installed packages on perl

Lets say that you are using the external vendor's hosted environment or somehow you don't know the inner things on your perl installations. how do you check the installed packages on the server using perl script?

I came through the same scenario when i intended to use CGI::Cookie Package. I was unable to check the package availability. then found the following script on web after some search and filter. when applied on my site, I got the full list of installed packages


use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "Version Not Found";
print "$module — $version
";
}


This piece of code returns the list of packages and their versions on the system.