Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

List all perldoc FAQs

by Dietz (Curate)
on Sep 18, 2006 at 16:44 UTC ( #573577=snippet: print w/ replies, xml ) Need Help??

Description:

This will list all FAQs from perlfaq[1-9] without their answers. Just a modification of subroutines from Pod::Perldoc.

Sample output:

$ perldocfaqs What is Perl? Who supports Perl? Who develops it? Why is it free? ..snip... What machines support perl? Where do I get it? ...snip... How do I fetch/put an FTP file? How can I do RPC in Perl?
Lists all FAQs line by line

$ perldocfaqs -n [perlfaq1 - 01] What is Perl? [perlfaq1 - 02] Who supports Perl? Who develops it? Why is it free? ...snip... [perlfaq2 - 01] What machines support perl? Where do I get it? ...snip... [perlfaq9 - 25] How do I fetch/put an FTP file? [perlfaq9 - 26] How can I do RPC in Perl?
Called with '-n' lists all FAQs with leading file info and faq number
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename 'fileparse';
use Pod::Perldoc;

my $show_faqnums = (shift||0) eq '-n' ? 1 : 0;
@ARGV = qw(-oText -q.);

no warnings 'redefine';

sub Pod::Perldoc::search_perlfaqs {
  my ($self, $found_things, $pod) = @_;
  local $_;
  for my $file (@$found_things) {
    my $perlfaq = fileparse($file, qr/\.pod/);
    open(INFAQ, '<', $file) or die "$file: $!\n";
    my $faqnum = sprintf '%02d', 1;
    while (<INFAQ>) {
      if (/^=head2\s/) {
        $show_faqnums and substr($_, 7, 0, "[$perlfaq - $faqnum]  ");
        push @$pod, "$_\n";
        $faqnum++;
      }
    }
    close(INFAQ);
  }
  return;
}

sub Pod::Perldoc::page {
  my ($self, $output) = @_;
  open(TMP, '<', $output) or die "$output: $!\n";
  local $_;
  while (<TMP>) {
    s/^\s+//;
    print or die "$!\n";
  }
  close TMP or die "$output: $!\n";
  $self->unlink_if_temp_file($output);
  return;
}

Pod::Perldoc->run();

Comment on List all perldoc FAQs
Download Code
Re: List all perldoc FAQs
by wazoox (Prior) on Sep 18, 2006 at 20:49 UTC
    Now what would be nice : enhance this to build automatically a quiz game :)

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://573577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-10-20 22:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (92 votes), past polls