xenchu has asked for the wisdom of the Perl Monks concerning the following question:
I know I am overlooking something obvious. I wrote this tiny program to learn what modules are installed on my machine:
When I run it, all I get back is the word Perl. Anyone want to stop laughing long enough to tell me the mistake I am making?use strict; use ExtUtils::Installed; my $module; my $inst = ExtUtils::Installed->new(); my (@modules) = $inst->modules(); foreach $module (@modules) { print "$module \n"; }
xenchu
Update:Well, actually I was expecting to see the Perl source distribution modules. According to the perldoc ExtUtils::Installed it is supposed to print all the modules on my system. I will try another way and if it works I will put it here. Thanks to both of you.
Update2:OK, here is the code I came up with:
I am sure that there is a better way to do this. And btw, I have only the standard modules on this machine, a condition I plan to rectify. Anyway, thanks again.use strict; use File::Find; my @files; find sub { push @files, $File::Find::name if -f _ && /\.pm$ +/ }, @INC; my ($mod, $hash, $name); my (@results, %hash, @results2); @results = map {/.+\/.+\/(.*).pm$/} @files; $hash{$_}++ foreach (@results); foreach (sort keys %hash) { print "$_.pm \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Installed Modules
by Zaxo (Archbishop) on Dec 07, 2003 at 04:42 UTC | |
|
Re: Installed Modules
by ysth (Canon) on Dec 07, 2003 at 05:20 UTC |