| 1 |
#!/usr/bin/env perl |
| 2 |
# pmpath -- show path to a perl module |
| 3 |
|
| 4 |
# ------ pragmas |
| 5 |
use strict; |
| 6 |
use warnings; |
| 7 |
|
| 8 |
our $VERSION = '2.0.0'; |
| 9 |
|
| 10 |
# ------ define variables |
| 11 |
my $errors = 0; # error count |
| 12 |
my $fullpath = undef; # full path |
| 13 |
my $module = undef; # module name |
| 14 |
my $shortpath = undef; # short path |
| 15 |
|
| 16 |
BEGIN { $^W = 1 } |
| 17 |
|
| 18 |
$errors = 0; |
| 19 |
|
| 20 |
for $module (@ARGV) { |
| 21 |
eval "local \$^W = 0; require $module"; |
| 22 |
if ($@) { |
| 23 |
$@ =~ s/at \(eval.*$//; |
| 24 |
warn "$0: $@"; |
| 25 |
$errors++; |
| 26 |
next; |
| 27 |
} |
| 28 |
for ($shortpath = $module) { |
| 29 |
s{::}{/}g; |
| 30 |
s/$/.pm/; |
| 31 |
} |
| 32 |
# print "$module is in " if @ARGV > 1; |
| 33 |
if (defined($fullpath = $INC{$shortpath})) { |
| 34 |
print "$fullpath\n"; |
| 35 |
} |
| 36 |
else { |
| 37 |
$errors++; |
| 38 |
warn "$0: path unavailable in %INC\n"; |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
exit ($errors != 0); |
| 43 |
|
| 44 |
__END__ |
| 45 |
|
| 46 |
=head1 NAME |
| 47 |
|
| 48 |
pmpath - show full path to a perl module |
| 49 |
|
| 50 |
=head1 SYNOPSIS |
| 51 |
|
| 52 |
pmpath module ... |
| 53 |
|
| 54 |
=head1 DESCRIPTION |
| 55 |
|
| 56 |
For each module name given as an argument, produces its full path on |
| 57 |
the standard output, one per line. |
| 58 |
|
| 59 |
=head1 EXAMPLES |
| 60 |
|
| 61 |
$ pmpath CGI |
| 62 |
/usr/local/devperl/lib/5.00554/CGI.pm |
| 63 |
|
| 64 |
$ filsperl -S pmpath IO::Socket CGI::Carp |
| 65 |
/usr/local/filsperl/lib/5.00554/i686-linux-thread/IO/Socket.pm |
| 66 |
/usr/local/filsperl/lib/5.00554/CGI/Carp.pm |
| 67 |
|
| 68 |
$ oldperl -S pmpath CGI CGI::Imagemap |
| 69 |
/usr/lib/perl5/CGI.pm |
| 70 |
/usr/lib/perl5/site_perl/CGI/Imagemap.pm |
| 71 |
|
| 72 |
=head1 SEE ALSO |
| 73 |
|
| 74 |
pmdesc(1), |
| 75 |
pmvers(1), |
| 76 |
pmcat(1). |
| 77 |
|
| 78 |
=head1 AUTHORS and COPYRIGHTS |
| 79 |
|
| 80 |
Copyright (C) 1999 Tom Christiansen. |
| 81 |
|
| 82 |
Copyright (C) 2006-2014 Mark Leighton Fisher. |
| 83 |
|
| 84 |
=head1 LICENSE |
| 85 |
|
| 86 |
This is free software; you can redistribute it and/or modify it |
| 87 |
under the terms of either: |
| 88 |
(a) the GNU General Public License as published by the Free |
| 89 |
Software Foundation; either version 1, or (at your option) any |
| 90 |
later version, or |
| 91 |
(b) the Perl "Artistic License". |
| 92 |
(This is the Perl 5 licensing scheme.) |
| 93 |
|
| 94 |
Please note this is a change from the |
| 95 |
original pmtools-1.00 (still available on CPAN), |
| 96 |
as pmtools-1.00 were licensed only under the |
| 97 |
Perl "Artistic License". |