use strict; use IO::File; my $PODDIR = '/usr/share/perl/5.8.8/pod/'; my $CACHEDIR = "$ENV{HOME}/.podcache"; opendir(my $dir,$PODDIR) or die("failed to open pod directory"); unless(-d $CACHEDIR){ mkdir($CACHEDIR) or die("failed to build cache directory"); } while(my $f=readdir($dir)){ next unless $f =~ /\.pod$/; my $cache_file = "$CACHEDIR/$f.txt"; next if -f $cache_file; my $cache_fh = IO::File->new($cache_file,"w") or die("failed to build cachefile $cache_file"); my @pod = `perldoc -t $PODDIR/$f`; for my $line (@pod){ print $cache_fh $line; } } my $pattern = $ARGV[0]; print `grep -r $pattern $CACHEDIR`