#!/usr/bin/perl -w # faqgrep-0.2 use strict; # Configuration: change $faqdir to point to the .pod sources # of the perlfaqs on your system: my $faqdir = '/usr/local/lib/perl5/5.8.2/pod'; my($opt_f,$opt_or,$pattern); while($ARGV[0]=~/^-/){ $_=$ARGV[0]; if (/^-or$/){$opt_or=1;shift @ARGV;next} if (/^-f$/){$opt_f=1;shift @ARGV;next} die<) { if (m/^=head(?:$pattern)/io) { print "$faq:$_" ; if ($opt_f) { while(){ last if m/^=head(?!$pattern)/io; print; } } } } close FAQ; } __END__ =head1 NAME faqgrep - perl script to search perlfaqs =head1 SYNOPSIS faqgrep [-f] [-or] [keywords...] faqgrep sort hash faqgrep -or sort hash faqgrep -f sort array =head1 DESCRIPTION This script takes keywords as arguments and searches through the perlfaqs printing on STDOUT the questions (and optionally the answers) which contain the keywords. =over 2 =item -or By default, keywords are 'ANDed' together to find questions which contain ALL of the keywords. Using the B<-or> option 'ORs' together the keywords to find questions which contain ANY of the keywords. =item -f By default only the matching questions are printed. Using this option causes the full entry (answer) of all matching questions to be printed. This can cause a lot of output unless the search was restricted. It is recommended that you first search for just one or two keywords and see the resulting matches and then repeat the search using B<-f> and additional keywords to restrict output to just those entries you wish to see. =back =head1 AUTHOR Andrew L. Johnson =head1 COPYRIGHT Copyright 1997-1998 Andrew L Johnson. This is free software and you may redistribute it and/or modify it under the same terms as Perl itself. =cut