The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/local/bin/perl

use 5.008;

use strict;
use warnings;

use CPAN::Access::AdHoc;
use Getopt::Long 2.33 qw{ :config auto_version };
use Pod::Usage;

our $VERSION = '0.000_194';

my %opt;

GetOptions( \%opt,
    qw{ cpan=s },
    help => sub { pod2usage( { -verbose => 2 } ) },
) and @ARGV or pod2usage( { -verbose => 0 } );

my $cad = CPAN::Access::AdHoc->new( cpan => $opt{cpan} );

my $index = $cad->fetch_module_index();

foreach my $module ( @ARGV ) {
    if ( my $data = $index->{$module} ) {
	print "$module\t$data->{version}\t$data->{distribution}\n";
    } else {
	print "$module not found\n";
    }
}

__END__

=head1 TITLE

mod-dist - Get the distribution that contains a module.

=head1 SYNOPSIS

 mod-dist LWP::UserAgent
 mod-dist -help
 mod-dist -version

=head1 OPTIONS

=head2 -cpan

This option specifies the URL of the CPAN repository.

=head2 -help

This option displays the documentation for this script. The script then
exits.

=head2 -version

This option displays the version of this script. The script then exits.

=head1 DETAILS

This Perl script queries the distribution index of the desired CPAN
repository, and reports which distribution contains each of the modules
specified on the command line.

=head1 AUTHOR

Thomas R. Wyant, III F<wyant at cpan dot org>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2012-2014 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text
of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.

=cut

# ex: set textwidth=72 :