in reply to Module Finder
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Module Finder
by Dietz (Curate) on Oct 19, 2006 at 06:21 UTC | |
by innominate (Beadle) on Oct 31, 2006 at 15:26 UTC | |
by Dietz (Curate) on Oct 31, 2006 at 16:42 UTC | |
Re^2: Module Finder
by innominate (Beadle) on Oct 31, 2006 at 15:22 UTC |