| 1 |
#!/usr/bin/env perl |
| 2 |
# pman -- show a module's man page |
| 3 |
|
| 4 |
# ------ pragmas |
| 5 |
use strict; |
| 6 |
use warnings; |
| 7 |
use pmtools; |
| 8 |
|
| 9 |
our $VERSION = '2.1.0'; |
| 10 |
|
| 11 |
# ------ define variables |
| 12 |
my $module; # module name |
| 13 |
my $pager; # $ENV{PAGER} - pager program |
| 14 |
my $path; # path for pod2text |
| 15 |
|
| 16 |
BEGIN { $^W = 1 } |
| 17 |
BEGIN { die "usage: $0 module ...\n" unless @ARGV } |
| 18 |
|
| 19 |
use FindBin qw($Bin); |
| 20 |
|
| 21 |
unless ($pager = $ENV{PAGER}) { |
| 22 |
require Config; |
| 23 |
$pager = $Config::Config{"pager"} || "more"; |
| 24 |
} |
| 25 |
|
| 26 |
for $module (@ARGV) { |
| 27 |
$module =~ s#::#/#gmsx; |
| 28 |
my $found = 0; |
| 29 |
my $iter = pmtools::new_pod_iterator($module); |
| 30 |
|
| 31 |
while (my $pod = $iter->()) { |
| 32 |
if (-s $pod) { |
| 33 |
$path = $pod; |
| 34 |
$found++; |
| 35 |
last; |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
if (!$found) { |
| 40 |
next; |
| 41 |
} |
| 42 |
system "$^X -S pod2text $path | $pager"; |
| 43 |
} |
| 44 |
|
| 45 |
exit(0); |
| 46 |
|
| 47 |
__END__ |
| 48 |
|
| 49 |
=head1 NAME |
| 50 |
|
| 51 |
pman - show a module's man page |
| 52 |
|
| 53 |
=head1 DESCRIPTION |
| 54 |
|
| 55 |
Send a module's pod through pod2text and your pager. |
| 56 |
|
| 57 |
This is mostly here for people too lazy to type |
| 58 |
|
| 59 |
$ pod2text `pmpath CGI` | $PAGER |
| 60 |
|
| 61 |
=head1 EXAMPLES |
| 62 |
|
| 63 |
$ pman CGI |
| 64 |
$ pman Curses |
| 65 |
|
| 66 |
Or running under different versions of Perl: |
| 67 |
|
| 68 |
$ oldperl -S pman CGI |
| 69 |
$ filsperl -S pman Threads |
| 70 |
|
| 71 |
=head1 SEE ALSO |
| 72 |
|
| 73 |
pod2text(1), perlpod(1), pod2man(1), pod2html(1). |
| 74 |
|
| 75 |
=head1 AUTHORS and COPYRIGHTS |
| 76 |
|
| 77 |
Copyright (C) 1999 Tom Christiansen. |
| 78 |
|
| 79 |
Copyright (C) 2006-2014, 2018 Mark Leighton Fisher. |
| 80 |
|
| 81 |
=head1 LICENSE |
| 82 |
|
| 83 |
This is free software; you can redistribute it and/or modify it |
| 84 |
under the terms of either: |
| 85 |
(a) the GNU General Public License as published by the Free |
| 86 |
Software Foundation; either version 1, or (at your option) any |
| 87 |
later version, or |
| 88 |
(b) the Perl "Artistic License". |
| 89 |
(This is the Perl 5 licensing scheme.) |
| 90 |
|
| 91 |
Please note this is a change from the |
| 92 |
original pmtools-1.00 (still available on CPAN), |
| 93 |
as pmtools-1.00 were licensed only under the |
| 94 |
Perl "Artistic License". |