in reply to It does exactly the opposite of what I want it to!

# This implements the logical recursion that we use to # cheat the order find() imposes;
Perhaps you don't realize that you can control the order in which File::Find descends, at least in 5.6:
`preprocess' The value should be a code reference. This code reference is us +ed to preprocess a directory; it is called after readdir() but before + the loop that calls the wanted() function. It is called with a list + of strings and is expected to return a list of strings. The code c +an be used to sort the strings alphabetically, numerically, or to fil +ter out directory entries based on their name alone.
So, for example, if you wanted all subdirectories to be processed after files, you could add:
... preprocess => sub { sort { -d $a <=> -d $b } @_ }, ...
to the argument list (see the docs). I haven't played with this, because I'm still on 5.5.3 waiting for 5.6.1, but give it a whirl if you're already in the "new" zone.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE: Re: It does exactly the opposite of what I want it to!
by merlyn (Sage) on Sep 22, 2000 at 21:52 UTC
    In fact, it appears that you can use 5.6's File::Find "out of the box", since on re-reading your code, you appear to just want to descend into both symlinks and "real" directories, in that order, and 5.6's find() can be told to chase links (reliably, I might add, without a chance for looping).

    -- Randal L. Schwartz, Perl hacker

      First off, I'm in 5.5.3 (5.005_03)...so I can't tweak it.

      However, what I want to do is, given the directory structure I posted above I want to follow the following logic:

      1. Parse any perlish files (determined by the shabang line...but this works) in the directory
      2. If there is a symlink to a directory, and the symlink is named "bin" or "current" go look at it, and don't look at any of the other directories.
      3. failing that, look in all the directories. (start at #1 for each, etc, recursing down).

      At the moment what it does is give me all the directories I don't want, and doesn't give me the one I do. I need a strategically placed !, but I can't quite figure out where to put it.