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


in reply to ExtUtils::Installed doesn't list all modules

rinceWind wrote (originally at 13:51 GMT +5 on 24 Sept 06):

Sadly, I find that EU::I is missing huge swathes of modules on my system. Diving into the code, I find that it only looks in two places: $config{archlibexp} and $config{sitearchexp}. Why oh why, I ask myself, just these special places? Surely the code should be traversing @INC. Heck, you could even have custom directories added via use lib or $ENV{PERL5LIB} that you want to be visible.

I've just looked at the code for ExtUtils::Installed and I have some answers. Not the asked-for solutions, but some answers. It's become de rigeur to bash ExtUtils:: generally (?). My opinion is: let's at least be correct when we do.

Why, I ask myself, just these special places? Surely the code should be traversing @INC. The code is traversing @INC in its search for the module names found via the mechanism I will describe shortly. See line 116 in the ExtUtils/Installed.pm shipped with perl-5.8.8 by ActiveState, for example (that's 0.08). Or refer to the code to follow my explanation if you don't have an editor or other Web tab open on the source already. See the new() subroutine specifically.

The new sub defines two vars as below:

my $archlib = $Config{archlibexp}; my $sitearch = $Config{sitearchexp};
and IMHO these two vars need to be joined by a third var, $Config{vendorarchexp}. That's a flaw in the module under almost any reasonable scope of expectations that I can conjure in my mind. However, it is not unreasonable that these two existing Config vars are used as they are, and this use is not limiting the scope of the search in exactly the manner explained by the OP. The reason for examining only FOOarchexp is that the values associated with each are the locations under which .packlist files are found.

The .packlist files (familiar to those of us who watch the actions of module installers (ExtUtils::MM, Module::Build) closely) were installed when each module was added to the Perl installation. ExtUtils::Installed is using the presence of these .packlist files as a means to the end of listing what modules have been installed.

Edit 25.09.06: correct next statement

It does not read the .packlist file in order to locate the module, you'll notice (because you are really reading the code by now, right? -- because it's more interesting than this long-winded explanation); ... the code simply takes note of the path to each (under .../auto/ ) and then creates a module name from that pathname. This is pretty reasonable behavior actually (in my analysis) in that it correlates well with how Perl's long-established mechanisms for how module management works.

    Soren A / somian / perlspinr / Intrepid

-- 
Words can be slippery, so consider who speaks as well as what is said; know as much as you can about the total context of the speaker's participation in a forum over time, before deciding that you fully comprehend the intention behind those words. If in doubt, ask for clarification before you 'flame'.