But then you have to do the Module to Module-partial-path yourself, mentally. Not that hard, indeed. And one may actually prefer it that way. I wouldn't. However what's more important is that you're transversing all @INC recursively whereas you already know the potential locations for the wanted package. Also suppose you want to find the location of That::Particular::Foo. With your method unless I'm missing something, you're bound to search for 'Foo', and with your match you'll also get not only That::Other::Foo, but also That::Particular::eFoOZ. Last, there are indeed case insensitive (but case preserving) fs'es in widespread use, however case does matter for [Pp]erl, so I would most definitely avoid /i.

I would proceed like thus instead:

#!/usr/bin/perl use strict; use warnings; use File::Spec::Functions; die "Usage: $0 <module> [<modules>]\n" unless @ARGV; ($\,$,)=("\n")x2; for my $mod (@ARGV) { print "Searching for `$mod':"; $mod =~ s{::}{/}g; $mod .= '.pm'; my @results=grep -f, map {catfile $_, $mod} @INC; warn "`$mod' not found\n" and next unless @results; print @results, ''; } __END__

Of course if you don't mind your particular module being actually loaded, and you generally shouldn't care, then you may ask perl to tell you where it found it, inspecting %INC:

C:\temp>perl -MFile::Find -le "print $INC{'File/Find.pm'}" C:/Programmi/Perl/lib/File/Find.pm

In reply to Re: Module Finder by blazar
in thread Module Finder by innominate

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.