Re: whichpm
by Aristotle (Chancellor) on Jul 16, 2003 at 07:54 UTC
|
I've been using something nearly identical for a while - even named it whichpm as well.
use strict;
use warnings;
use File::Spec::Functions qw(catfile);
my @loaded = grep {
eval "require $_";
!$@ ? 1 : ($@ =~ s/\(\@INC contains: \Q@INC\E\)//, warn("Failed lo
+ading $_: $@"), 0);
} @ARGV;
my @pm = map catfile(split '::') . (/\.pm\z/ ? '' : '.pm'), @loaded;
print "@INC{@pm}\n";
Makeshifts last the longest. | [reply] [d/l] |
Re: whichpm
by cchampion (Curate) on Jul 16, 2003 at 08:16 UTC
|
$ perldoc -l modulename would give you exactly the same result.
Or am I missing something?
$ perldoc -l HTML::Parser
/usr/lib/perl5/site_perl/5.6.1/i386-linux/HTML/Parser.pm
| [reply] [d/l] |
|
The command perldoc -l gives the location of the pod which might not be the same file as the source code, for example:
$ perldoc -l Inline::C
/usr/local/perl/lib/site_perl/5.6.1/Inline/C.pod
--
John.
| [reply] [d/l] |
Re: whichpm
by PodMaster (Abbot) on Jul 16, 2003 at 11:07 UTC
|
I recently ran accross Module::InstalledVersion, somewhat similar in its purpose.
Neither you nor it pay attention to the dynamic environment variables PERLLIB, PERL5LIB. Just letting you know ;)
Also, you've already got the pod, so The Dynamic Duo --or-- Holy Getopt::Long, Pod::UsageMan! ;)
update: duuuuh, I think what I was trying to say is that maybe
you shouldn't be actually requireing the module, kinda like what Module::Info info does (hey, you could use Module::Info), but since you're actually editing it ++/duck
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] |
|
I had actually thought about these vars,
but assumed that require would handle the
magic. I'll test it, if it doesn't it's a
simple matter of a BEGIN block to split
the vars and <s>push</s> unshift them
onto @INC.
UPDATE:
As Aristotle got around to showing before
I did, the vars are heeded
Oh umm, okay... Why not?
I actually used require intentionally.
Let perl do the heavy lifting ;-)
It even works for broken modules which
don't return true (but not null length files).
--
I'm not belgian but I play one on TV.
| [reply] |
|
$ PERL5LIB="--->HERE<---" perl -le'print "@INC\n"'
--->HERE<--- /usr/lib/perl5/5.8.0/i386-linux /usr/lib/perl5/5.8.0 /usr
+/lib/perl5/site_perl/5.8.0/i386-linux /usr/lib/perl5/site_perl/5.8.0
+/usr/lib/perl5/site_perl .
Makeshifts last the longest. | [reply] [d/l] |
whichpm = pmpath
by bsb (Priest) on Jul 24, 2003 at 05:22 UTC
|
pmpath in pmtools (by tchrist) does this, I think.
Here's some other goodies in pmtools.
This is from the dpkg description of pmtools:
Description: Perl module tools
Perl module tools is a suite of small tools that help manage and insp
+ect
perl modules, perl Plain Old Documentation files, and perl programs.
.
Some of the things these tools can do include:
- show the full path to a module
- show the version and description of a module
- list all installed modules with descriptions
- show what files a given program or module loads at compile time
- show what symbols a module exports
- list the methods of a class
- display the source code of a function of a module
| [reply] [d/l] |
Re: whichpm
by halley (Prior) on Jul 16, 2003 at 17:12 UTC
|
My homegrown version started from an example in the Cookbook. I manually walk the @INC and get other module information like $VERSION and =head1 NAME summaries. With an extra option, I can also find shadowing where some yokel has defined a module with the same name as a corporate site-perl module.
-- [ e d @ h a l l e y . c c ] | [reply] |
|
That would be a wherepm, which could also be useful on occasion.
--
In Bob We Trust, All Others Bring Data.
| [reply] [d/l] |
Re: whichpm
by zentara (Archbishop) on Jul 17, 2003 at 15:01 UTC
|
I had this one in my library collection:
#!/usr/bin/perl
#usage $0 Some::Module
($f=($m=shift).".pm")=~s{::}{/}g;
eval "require $m" and print $INC{$f},$/;
#1liner
# perl -e '($f=($m=shift).".pm")=~s{::}{/}g; \
# eval "require $m" and print $INC{$f},$/' File::Find
#also
#perldoc -l Some::Module
| [reply] [d/l] |