#!/usr/bin/perl -w use strict; my $perl_module; BEGIN { my $ct_args = @ARGV; if ($ct_args != 1) { print "\nUsage: pwhich <perl module name>\n\n"; print "Example: pwhich DBI\n\n"; exit; } $perl_module = shift; }; eval "use $perl_module"; die "Can't find Perl module $perl_module!\n" if $@; my $inc_key = "$perl_module.pm"; $inc_key =~ s!::!/!g; print "inc_key = $inc_key\n"; my $abs_filename = $INC{$inc_key}; print "\n"; print "Module: $perl_module\n"; print "Location: $abs_filename\n"; open(IN,"<$abs_filename") || die "Can't open $abs_filename!"; my $version = ""; while (<IN>) { if (/\s*\$[\w:]*VERSION\s*=[ "']*([0-9_\.]+)/i) { $version = $1; last; } } close(IN); print "Version: $version\n\n";
In reply to Re: module location
by hmerrill
in thread module location
by hmerrill
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |