in reply to Skipping directories using File::Find

Set $File::Find::prune = 1 before you return for a sub-directory tree you wish to skip.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Skipping directories using File::Find
by doof (Initiate) on Jan 25, 2006 at 10:58 UTC
    Im not sure exactly what you mean by that, at what point should i set $File::Find::prune = 1?
    this is what i have:

    find(\&edits, $dir);
    sub edits { push @$cont, $File::Find::name, stat($File::Find::name) if (!($File::Find::name =~ /.snapshot/)); }
      find(\&edits, $dir); sub edits { if ($should_prune) { $File::Find::prune = 1 return; } push @$cont, $File::Find::name, stat($File::Find::name) if (!($File::Find::name =~ /.snapshot/)); }

      DWIM is Perl's answer to Gödel
        But this will still search through the directory wont it? the find function is the one thats doing the traversing so isn't it too late to deal with it in the edits() function?