http://www.perlmonks.org?node_id=1042737

mwhiting has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks. I have a little snippet of code I used to use to check to see if CGI::Session is installed on a server:
use ExtUtils::Installed; my $installed = ExtUtils::Installed->new(); print "and ..."; if (grep(/CGI::Session/,$installed->modules() )) { print "found it."; } else { print "didn't find it."; } exit;
This check doesn't seem to work anymore ... I have CGI:Session installed and it works fine, but this routine doesn't show it. I have a similar one to show all installed modules:
print "<p>Finding all installed modules...<br>\n"; my $installed2 = ExtUtils::Installed->new(); foreach my $module ($installed2->modules) { my $version = $installed2->version($module) || "<no version info>"; print("Found module $module Version $version<br>\n"); }
and it only shows the perl core:
Finding all installed modules... Found module Perl Version 5.10.0 Script finished.

I would actually prefer an all-perl solution that doesn't use grep so it is more OS-independent .... but why doesn't this show me any installed module names? (or ... hmmm, is Session part of the core now?)

Thanks!

Replies are listed 'Best First'.
Re: ExtUtils::Installed .... has it changed?
by syphilis (Archbishop) on Jul 06, 2013 at 00:02 UTC
    ExtUtils::Installed determines what modules have been installed by examining the '.packlist' files created during module installation. If you install CGI::Session via a method that doesn't create a .packlist file, then CGI::Session won't be found by ExtUtils::Installed.

    Do you have a .packlist file for CGI::Session ?
    On my windows box the relevant .packlist would be found in perl/site/lib/auto/CGI/Session, though it wouldn't hurt to check that Session.pm is not listed in the .packlist one directory back (which would be perl/site/lib/auto/CGI/.packlist on this Windows box).

    If CGI/Session.pm *is* being specified in a .packlist, then we need to work out why your script fails to list it - otherwise you have the answer as to why it's not being listed.

    Cheers,
    Rob