#!/usr/bin/perl 

# Author: Chan Bernard Ki Hong (2003)
# Find modules loadable by Perl, and their paths on disk
# (sort of like the perldiver CGI script)

use FileSearch;

my $search = new FileSearch('PATTERN' => '^.*\.pm$');

my @results = ();
my %results2 = ();
foreach $path (reverse @INC) {
	push @results, map { 
		s/^$path\/(.*)$/$1/; 
		{
			'name' => $_,
			'path' => $path,
		}; 
	} $search->find($path);
}

foreach (@results) {
	my $clsname = $_->{'name'};
	$clsname =~ s/^(.*)\.pm$/$1/;
	$clsname =~ s/\//::/g;
	$results2{$clsname} = $_->{'path'};
}

foreach (sort keys %results2) {
	print "$_ ($results2{$_})\n";
}
