Skip to content

Commit

Permalink
Added recurse option for Pod::Simple's search
Browse files Browse the repository at this point in the history
  • Loading branch information
dafrito committed Aug 16, 2011
1 parent 2734f72 commit 54ca696
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/Pod/Simple/Search.pm
Expand Up @@ -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',
);
#==========================================================================

Expand All @@ -39,6 +39,7 @@ sub new {
sub init {
my $self = shift;
$self->inc(1);
$self->recurse(1);
$self->verbose(DEBUG);
return $self;
}
Expand Down Expand Up @@ -127,16 +128,23 @@ 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 {
($file, $shortname, $isdir, $modname_bits) = @_;

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';
Expand Down

0 comments on commit 54ca696

Please sign in to comment.