I saw this tip this morning from another list - there is a
perldoc -l <module name>
(that's a minus small L option) command that will tell you where in the @INC perl path the module exists. For example, on my system if I do
perldoc -l DBI
it spits this back:
/usr/lib/perl5/site_perl/5.005/i386-linux/DBI.pm
So I enhance that a little with this script that I called "pwhich":
---------------------------------------
#!/usr/bin/perl -w
#############################################################################
# Name: pwhich
# Purpose: Perl version of "which" command
# Takes In: 1. Perl module name (Ex: DBI, DBD::Oracle)
#
# Writes Out: Either a. "No documentation found for "XYZ"
#
# where "XYZ" is the name of a Perl module specified
# by the user that does *NOT* exist,
#
# Or b. line 1 - the @INC location of the perl module, and
# line 2 - the $Id version of the perl module
#############################################################################
use strict;
my $ct_args = @ARGV;
if ($ct_args != 1) {
print "\nUsage: pwhich <perl module name>\n\n";
print "Example: pwhich DBI\n\n";
exit;
}
my $perl_module = shift;
my $abs_filename = `perldoc -l $perl_module 2>&1`;
print "\n";
print "$abs_filename";
if ($abs_filename =~ /^No documentation found/) {
print "\n";
exit;
}
chomp($abs_filename);
open(IN,"<$abs_filename"
|| die "Can't open $abs_filename!";
while (<IN>) {
if (/\s*\$[\w:]*VERSION\s*=/) {
print;
last;
}
}
close(IN);
print "\n";
---------------------------------------
If I now run this
pwhich DBI
it spits this back:
/usr/lib/perl5/site_perl/5.005/i386-linux/DBI.pm
$DBI::VERSION = "1.15"; # ==> ALSO update the version in the pod text below!
Thought some people here might find this useful.
Hardy Merrill
Mission Critical Linux, Inc.
perldoc -l <module name>
(that's a minus small L option) command that will tell you where in the @INC perl path the module exists. For example, on my system if I do
perldoc -l DBI
it spits this back:
/usr/lib/perl5/site_perl/5.005/i386-linux/DBI.pm
So I enhance that a little with this script that I called "pwhich":
---------------------------------------
#!/usr/bin/perl -w
#############################################################################
# Name: pwhich
# Purpose: Perl version of "which" command
# Takes In: 1. Perl module name (Ex: DBI, DBD::Oracle)
#
# Writes Out: Either a. "No documentation found for "XYZ"
#
# where "XYZ" is the name of a Perl module specified
# by the user that does *NOT* exist,
#
# Or b. line 1 - the @INC location of the perl module, and
# line 2 - the $Id version of the perl module
#############################################################################
use strict;
my $ct_args = @ARGV;
if ($ct_args != 1) {
print "\nUsage: pwhich <perl module name>\n\n";
print "Example: pwhich DBI\n\n";
exit;
}
my $perl_module = shift;
my $abs_filename = `perldoc -l $perl_module 2>&1`;
print "\n";
print "$abs_filename";
if ($abs_filename =~ /^No documentation found/) {
print "\n";
exit;
}
chomp($abs_filename);
open(IN,"<$abs_filename"
while (<IN>) {
if (/\s*\$[\w:]*VERSION\s*=/) {
print;
last;
}
}
close(IN);
print "\n";
---------------------------------------
If I now run this
pwhich DBI
it spits this back:
/usr/lib/perl5/site_perl/5.005/i386-linux/DBI.pm
$DBI::VERSION = "1.15"; # ==> ALSO update the version in the pod text below!
Thought some people here might find this useful.
Hardy Merrill
Mission Critical Linux, Inc.