From 54ca696484268c0278af6deb38baecf60f43eded Mon Sep 17 00:00:00 2001 From: Aaron Faanes Date: Tue, 16 Aug 2011 08:46:31 -0500 Subject: [PATCH] Added recurse option for Pod::Simple's search --- lib/Pod/Simple/Search.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Pod/Simple/Search.pm b/lib/Pod/Simple/Search.pm index 1ad76169a1..793c24af1e 100644 --- a/lib/Pod/Simple/Search.pm +++ b/lib/Pod/Simple/Search.pm @@ -25,7 +25,7 @@ use Cwd qw( cwd ); #========================================================================== __PACKAGE__->_accessorize( # Make my dumb accessor methods 'callback', 'progress', 'dir_prefix', 'inc', 'laborious', 'limit_glob', - 'limit_re', 'shadows', 'verbose', 'name2path', 'path2name', + 'limit_re', 'shadows', 'verbose', 'name2path', 'path2name', 'recurse', ); #========================================================================== @@ -39,6 +39,7 @@ sub new { sub init { my $self = shift; $self->inc(1); + $self->recurse(1); $self->verbose(DEBUG); return $self; } @@ -127,9 +128,11 @@ sub _make_search_callback { my $self = $_[0]; # Put the options in variables, for easy access - my( $laborious, $verbose, $shadows, $limit_re, $callback, $progress,$path2name,$name2path) = + my( $laborious, $verbose, $shadows, $limit_re, $callback, $progress, + $path2name, $name2path, $recurse) = map scalar($self->$_()), - qw(laborious verbose shadows limit_re callback progress path2name name2path); + qw(laborious verbose shadows limit_re callback progress + path2name name2path recurse); my($file, $shortname, $isdir, $modname_bits); return sub { @@ -137,6 +140,11 @@ sub _make_search_callback { if($isdir) { # this never gets called on the startdir itself, just subdirs + unless( $recurse ) { + $verbose and print "Not recursing into '$file' as per requested.\n"; + return 'PRUNE'; + } + if( $self->{'_dirs_visited'}{$file} ) { $verbose and print "Directory '$file' already seen, skipping.\n"; return 'PRUNE';