This will list all FAQs from perlfaq[1-9] without their answers. Just a modification of subroutines from Pod::Perldoc.
Sample output:
Lists all FAQs line by line$ 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?
Called with '-n' lists all FAQs with leading file info and faq number$ 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?
#!/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();
In reply to List all perldoc FAQs by Dietz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |