Sometimes you need to read the source of a module installed on your system, but you don't know if it is in '/usr/lib/perl/site-perl' or '/usr/lib/perl5/5.8.0/' or a dozen other directories in your @ISA. Or perhaps you have two versions of a library and you are not sure which one is used. With Module::Info this can be resolved quickly:
perl -MModule::Info -e ' my $mod = Module::Info->new_from_module("The: +:Module::You::Investigate"); print $mod->file'

Replies are listed 'Best First'.
Re: Find the file for a module
by davorg (Chancellor) on Apr 15, 2003 at 10:14 UTC

    perldoc has a couple of options that might make your life easier.

    To find the file that contains the module source code, just use perldoc -l Module::Name. To see the source code of a module use perldoc -m Module::Name.

    As always, perldoc perldoc for more information.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Find the file for a module
by broquaint (Abbot) on Apr 15, 2003 at 10:24 UTC
    As always, TIMTOWTDI
    perl -e '($f=($m=shift).".pm")=~s{::}{/}g; \ eval "require $m" and print $INC{$f},$/' Your::Module

    HTH

    _________
    broquaint

Re: Find the file for a module
by Aristotle (Chancellor) on Apr 15, 2003 at 20:47 UTC
    I've been using the following script, placed at ~/bin/whichpm.
    #!/usr/bin/perl use File::Spec::Functions qw(:ALL); $ARGV[0] or die "usage: $0 Module::Name\n"; my $subpath = catfile(split '::', $ARGV[0]).".pm"; for(@INC) { my $fullpath = catfile($_, $subpath); print("$fullpath\n"), exit if -f $fullpath; } die +(splitdir $0)[-1] . ": no such module $subpath\n";

    Makeshifts last the longest.

Re: Find the file for a module
by zby (Vicar) on Apr 15, 2003 at 10:08 UTC
    I am not sure of the title. Perhaps someone could propose a better one.