#!/usr/bin/env perl 
use strict;
use warnings;

use Getopt::Long;
my %args;
GetOptions( \%args, 'help|h' ) or exit;

@ARGV = grep { defined } @ARGV;

if ( $args{help} || !@ARGV ) {
    print <<'EOF';
USAGE: mwhere Module [ ... ]
EXAMPLES:
    mwhere Carp                                    # show location of Carp.pm
    mwhere Carp CGI                                # copy both Carp.pm and CGI.pm
EOF
    exit;
}

for my $mod (@ARGV) {
    eval "require $mod" or warn "failed to require '$mod'\n" and next;

    my @parts = split /::/, $mod;
    my $inc = join( '/', @parts ) . '.pm';
    my $source = $INC{$inc};
    print $source, "\n";
}

