For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > February 2005 > search perldocs against each word in a string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author search perldocs against each word in a string
ioneabu@yahoo.com

2005-02-16, 4:01 am

#!/usr/bin/perl
#file: pdoc.pl searches perldocs
use warnings;
use strict;
pdoc.pl "perldoc individual words string"
output:
perl5005delta
perl561delta
perl581delta
perlmodlib
perlos2
perlport

Is there anything built in that does this? It runs pretty fast
considering it has to load each perldoc into memory and compare against
each word in search string.

use File::Slurp;
use File::Find;
#file: pdoc.pl: search perldocs
my $string = $ARGV[0];
my @string = split /\s+/, $string;
my $count = scalar @string;
my $path = 'c:\perl\lib\pod';
find(\&wanted, $path);
sub wanted
{
my ($contents, $filename);
$filename = $File::Find::name;
if (/\.pod$/)
{
$contents = read_file($filename) ;
s/\.pod$//;
print $_ , "\n"
if $count == grep {$contents =~ /$_/i} @string;
}
}

#thanks!
#wana

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com