| 1 |
#!/usr/bin/env perl |
| 2 |
# podpath - print the path to the Pod |
| 3 |
|
| 4 |
# ------ pragmas |
| 5 |
use strict; |
| 6 |
use warnings; |
| 7 |
use pmtools; |
| 8 |
|
| 9 |
our $VERSION = '2.2.0'; |
| 10 |
|
| 11 |
for my $module (@ARGV) { |
| 12 |
if ( $module =~ /^perl/ ) { |
| 13 |
system("$^X -S stdpods | grep $module"); |
| 14 |
} else { |
| 15 |
$module =~ s#::#/#gmsx; |
| 16 |
my $found = 0; |
| 17 |
my $pod_iter = pmtools::new_pod_iterator($module); |
| 18 |
while (my $pod_file = $pod_iter->()) { |
| 19 |
next if !-s $pod_file; |
| 20 |
|
| 21 |
# in case we find the .pm before the .pod |
| 22 |
my $output = `grep '=head1' $pod_file`; |
| 23 |
if ($? == 0) { |
| 24 |
print "$pod_file\n"; |
| 25 |
$found++; |
| 26 |
last; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
if (!$found) { |
| 31 |
print STDERR "$0: Can't locate $module.pm or $module.pod " |
| 32 |
. "in \@INC (\@INC contains: " . join(' ', @INC) . ")\n"; |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
__END__ |
| 38 |
|
| 39 |
=head1 NAME |
| 40 |
|
| 41 |
podpath - print the path to the Pod |
| 42 |
|
| 43 |
=head1 DESCRIPTION |
| 44 |
|
| 45 |
podpath prints the path to the Pod. podpath calls stdpods underneath |
| 46 |
if the Pod name includes 'perl'. Otherwise, it searches down |
| 47 |
@INC, printing the '.pod' filename if there is a separate Pod |
| 48 |
file, otherwise printing the 'pm' filename. This accommodates |
| 49 |
systems where the Pod lives in a separate file from the module file. |
| 50 |
|
| 51 |
=head1 EXAMPLES |
| 52 |
|
| 53 |
$ podpath Cwd |
| 54 |
/usr/local/devperl/lib/5.00554/Cwd.pm |
| 55 |
|
| 56 |
It works with alternate installations, too: |
| 57 |
|
| 58 |
$ devperl -S podpath perlfunc |
| 59 |
/usr/local/devperl/lib/5.00554/pod/perlfunc.pod |
| 60 |
|
| 61 |
$ oldperl -S podpath IO::Handle |
| 62 |
/usr/lib/perl5/i386-linux/5.00404/IO/Handle.pm |
| 63 |
|
| 64 |
$ filsperl -S podpath Thread |
| 65 |
/usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread.pm |
| 66 |
|
| 67 |
=head1 SEE ALSO |
| 68 |
|
| 69 |
stdpods(1), |
| 70 |
pmpath(1), |
| 71 |
perlmodlib(1). |
| 72 |
|
| 73 |
=head1 AUTHORS and COPYRIGHTS |
| 74 |
|
| 75 |
Copyright (C) 1999 Tom Christiansen. |
| 76 |
|
| 77 |
Copyright (C) 2006-2014, 2018 Mark Leighton Fisher. |
| 78 |
|
| 79 |
=head1 LICENSE |
| 80 |
|
| 81 |
This is free software; you can redistribute it and/or modify it |
| 82 |
under the terms of either: |
| 83 |
(a) the GNU General Public License as published by the Free |
| 84 |
Software Foundation; either version 1, or (at your option) any |
| 85 |
later version, or |
| 86 |
(b) the Perl "Artistic License". |
| 87 |
(This is the Perl 5 licensing scheme.) |
| 88 |
|
| 89 |
Please note this is a change from the |
| 90 |
original pmtools-1.00 (still available on CPAN), |
| 91 |
as pmtools-1.00 were licensed only under the |
| 92 |
Perl "Artistic License". |