From: Gisle Aas Date: Wed, 5 Feb 1997 11:27:36 +0000 (+0100) Subject: perldoc -f X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=31bdbec1d6f429e8532f3bb66cddf8b47418f4fa;p=p5sagit%2Fp5-mst-13.2.git perldoc -f p5p-msgid: <199702051127.MAA02090@bergen.sn.no> --- diff --git a/utils/perldoc.PL b/utils/perldoc.PL index 7945712..b6f8bf9 100644 --- a/utils/perldoc.PL +++ b/utils/perldoc.PL @@ -45,8 +45,10 @@ print OUT <<'!NO!SUBS!'; # the perl manuals, though it too is written in perl. if(@ARGV<1) { + $0 =~ s,.*/,,; die < 1; if ($opt_t) { require Pod::Text; import Pod::Text; } -@pages = @ARGV; +if ($opt_f) { + @pages = ("perlfunc"); +} else { + @pages = @ARGV; +} + + sub containspod { my($file) = @_; @@ -224,7 +240,7 @@ if ($opt_l) { exit; } -if( ! -t STDOUT ) { $opt_f = 1 } +if( ! -t STDOUT ) { $no_tty = 1 } unless($Is_VMS) { $tmp = "/tmp/perldoc1.$$"; @@ -244,6 +260,41 @@ if ($opt_m) { exit $Is_VMS ? $sts : 1; } +if ($opt_f) { + my $perlfunc = shift @found; + open(PFUNC, $perlfunc) or die "Can't open $perlfunc: $!"; + + # Skip introduction + while () { + last if /^=head2 Alphabetical Listing of Perl Functions/; + } + + # Look for our function + my $found = 0; + while () { + if (/^=item\s+\Q$opt_f\E\b/o) { + $found++; + } elsif (/^=item/) { + last if $found; + } + push(@pod, $_) if $found; + } + if (@pod) { + if ($opt_t) { + open(FORMATTER, "| pod2text") || die "Can't start filter"; + print FORMATTER "=over 8\n\n"; + print FORMATTER @pod; + print FORMATTER "=back\n"; + close(FORMATTER); + } else { + print @pod; + } + } else { + die "No documentation for perl function `$func' found\n"; + } + exit; +} + foreach (@found) { if($opt_t) { @@ -277,7 +328,7 @@ foreach (@found) { } } -if( $opt_f ) { +if( $no_tty ) { open(TMP,"<$tmp"); print while ; close(TMP); @@ -303,6 +354,8 @@ perldoc - Look up Perl documentation in pod format. B [B<-h>] [B<-v>] [B<-t>] [B<-u>] [B<-m>] [B<-l>] PageName|ModuleName|ProgramName +B B<-f> BuiltinFunction + =head1 DESCRIPTION I looks up a piece of documentation in .pod format that is embedded @@ -346,6 +399,11 @@ the file for you and simply hand it off for display. Display the file name of the module found. +=item B<-f> perlfunc + +The B<-f> option followed by the name of a perl built in function will +extract the documentation of this function from L. + =item B The item you want to look up. Nested modules (such as C)