in reply to script to check modules exist...

use Data::Dumper; my %g_modules; Traverse( $_ ) for ( @INC ); print Dumper \%g_modules; sub Traverse { my $dir = shift; opendir my $dh, $dir or die "$!: $dir\n"; for my $file ( grep !/^\./, readdir $dh ) { my $path = "$dir/$file"; if ( -d $path ) { Traverse ( $path ); } elsif ( $file =~ /\.pm$/ ) { $g_modules{ $file } = 1; } } closedir $dh; }

One world, one people

Replies are listed 'Best First'.
Re^2: script to check modules exist...
by toolic (Bishop) on May 02, 2011 at 15:04 UTC
    The results of your code are misleading because it tells me I only have one file named "Base.pm".
    'Base.pm' => 1,
    However, I have 22 installed files named "Base.pm"
    Chart/Base.pm DBD/Gofer/Policy/Base.pm DBD/Gofer/Transport/Base.pm DBI/Gofer/Serializer/Base.pm DBI/Gofer/Transport/Base.pm Date/Manip/Base.pm DateTime/Locale/Base.pm Exception/Class/Base.pm ExtUtils/CBuilder/Base.pm ExtUtils/Constant/Base.pm IO/Compress/Base.pm IO/Uncompress/Base.pm Log/Dispatch/Base.pm Module/Build/Base.pm Net/DNS/Resolver/Base.pm TAP/Base.pm TAP/Formatter/Base.pm URI/file/Base.pm XML/SAX/Base.pm YAML/Base.pm YAML/Dumper/Base.pm YAML/Loader/Base.pm
    See Find installed Perl modules matching a regular expression
      It is of course possible to store the full path as a hash key instead. But it is not easy to specify where the first part of the namespace begins from that, although a site-specific solution should be possible.

      One world, one people

Re^2: script to check modules exist...
by Anonymous Monk on May 03, 2011 at 10:05 UTC