in reply to Re: Skipping directories using File::Find
in thread Skipping directories using File::Find

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/)); }
  • Comment on Re^2: Skipping directories using File::Find

Replies are listed 'Best First'.
Re^3: Skipping directories using File::Find
by GrandFather (Saint) on Jan 25, 2006 at 11:15 UTC
    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?

        It prunes the tree at the current level so any directories below the current one will not be visited and if you return before the edit processing the contents of the current directory are not processed either.

        Remember that, in the normal course of events, edits() will be called for each directory in the tree. Setting prune modifies that behaviour.


        DWIM is Perl's answer to Gödel