<?xml version="1.0" encoding="windows-1252"?>
<node id="954149" title="Perldoc Keyword Search (update3)" created="2012-02-16 00:44:01" updated="2012-02-16 00:44:01">
<type id="1042">
CUFP</type>
<author id="708738">
LanX</author>
<data>
<field name="doctext">
&lt;h3&gt; ... or how to find X&lt;&gt;-refs in Pod and search them in pager&lt;/h3&gt;&lt;P&gt;

&lt;h4&gt;Problem&lt;/h4&gt;&lt;P&gt;

Did you ever try to find the documentation of the ".." (flip-flop) operator?&lt;P&gt;

typing &lt;c&gt;perldoc -f ..&lt;/c&gt; doesn't help ...&lt;P&gt;

&lt;c&gt;$ perldoc -f ..
No documentation for perl function `..' found
&lt;/c&gt;

But perldocs have tags like X&lt;..&gt; indicating the right documentation, only  the formatters are missing.

&lt;h4&gt;Previous discussions&lt;/h4&gt;
&lt;li&gt; [id://786762] or 
&lt;li&gt;[id://951485]&lt;P&gt;

&lt;h4&gt;Approach&lt;/h4&gt;
&lt;li&gt;Grep core-Pods for [doc://perlpod#Formatting-Codes|X&lt;TAGS&gt;].&lt;P&gt;&lt;P&gt;

&lt;li&gt;Insert marker in front of every hit.&lt;P&gt;&lt;P&gt;

&lt;li&gt;Call pager (here less) with default  search pattern to find those markers. &lt;P&gt;&lt;P&gt;

&lt;h4&gt;Usage&lt;/h4&gt;
&lt;li&gt; type &lt;c&gt;pdoc qr&lt;/c&gt; to find all references for qr.&lt;P&gt;&lt;P&gt;

&lt;li&gt;Typing &lt;c&gt;n&lt;/c&gt; and &lt;c&gt;N&lt;/c&gt; will jump from marker to marker.&lt;P&gt;&lt;P&gt;

&lt;li&gt;After quitting a manpage &lt;c&gt;q&lt;/c&gt;the next is built and displayed&lt;P&gt;

&lt;h4&gt; Prove of concept&lt;/h4&gt;&lt;P&gt;

Just a hack ("release often" dogma)&lt;P&gt;
Tested for linux.&lt;P&gt;

&lt;h5&gt;file "pdoc"&lt;/h5&gt;
&lt;c&gt;
#!/usr/bin/perl
 
use strict;
# use Data::Dump;
 
my $poddir =  `perldoc -l perltoc`;
chomp $poddir;
$poddir =~ s/perltoc/*/;
 
my $pattern = $ARGV[0];
my @pods= grep {! /perltoc/} `grep -l -F 'X&lt;$pattern&gt;' $poddir`;
chomp @pods;
 
# dd @pods;
 
for my $infile (@pods) {
  open my $in, "&lt;", $infile;
  my $outfile = "/tmp/". (split "/",$infile)[-1];
  open my $out,"&gt;", $outfile;
  
  local $/="\n\n";
  my $marker =
     "&gt;&gt;&gt; X&lt;$pattern&gt; &lt;&lt;&lt;";    #"MARK";
  
  while (my $para = &lt;$in&gt;){
  print $out "\nC&lt;&lt;&lt;&lt; $marker &gt;&gt;&gt;&gt;\n\n"
  	if $para =~ /X&lt;\Q$pattern\E&gt;/; 
 
  print $out $para;
  }
  close $out;
 
  my $ret = `pod2man $outfile |nroff -man &gt; /tmp/tmp.man`;
  print system("less -p \"$marker\" /tmp/tmp.man")
}
&lt;/c&gt;&lt;P&gt;&lt;P&gt;



&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-708738"&gt;
&lt;p&gt;Cheers Rolf
&lt;/div&gt;&lt;/div&gt;
</field>
</data>
</node>
