Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Help with File::Find

by SamQi (Beadle)
on Sep 18, 2000 at 22:13 UTC ( [id://32997]=perlquestion: print w/replies, xml ) Need Help??

SamQi has asked for the wisdom of the Perl Monks concerning the following question:

Okay...I'm moving my question from Q&A to here...

I'm writing a script to test for perl versions.

Now here are the requirements I want it to have:
  1. Don't recurse directories
    This much I've got mostly figured out, but am still a bit fuzzy on. It is bascially going to be at the top level of my search telling the script to just not touch some of the big directories that I don't *need* to search.
  2. Only test in the *current* bin directories:
    This part is what's really stumping me, I've sort of got it figured out, and it's more of an algorithm question than anything. We have it set up so that each project has a separate directory, and in that directory there is a symlink (each one may be named differently) that points to the directory with our current version. I want to follow that symlink and parse the directory it points to (as it's pointed to) So far I've come up with something of to the effect of:
    if(-l File::Find::name)
    { #dosomething with readlink File::Find::name }
    However, some of the directories I want to recurse into (most of them are at the top level of the tree I'm recursing) aren't going to have the symlink structure that I described above. However, inside those directories, there *is* the symlink structure.

I want to be able to just run my script in the directory at the top of the tree and let it recurse thru all the directories I want it to without having to hardcode locally dependant paths into the script.

Any ideas, monks?

Replies are listed 'Best First'.
Re: Help with File::Find
by ncw (Friar) on Sep 18, 2000 at 23:43 UTC
    As File::Find has been talked about so much recently, I've added a snippet about going it alone withouth File::Find here.

    You might find this code helpful as you can modify it to prune the recursion whenever you like.

Re: Help with File::Find
by merlyn (Sage) on Sep 18, 2000 at 22:15 UTC
Re: Help with File::Find
by SamQi (Beadle) on Sep 18, 2000 at 22:54 UTC

    Just for a bit of clarification...we're looking at a directory structure like this

    ./dir1
       bin --> bin3/
       bin1/
       bin2/
       bin3/
    ./dir2
       bin --> bin2/
       bin1/
       bin2/
    ./dir3
       subdir1
         bin --> bin2/
    (etc, so on)
    ./project1current --> /some/other/path/than/this
    ./www
    ./perl
    

    I want it to recurse into *only* these paths:

    ./dir1/bin3
    ./dir2/bin2
    ./dir3/subdir1/bin2/
    
    (etc so on in that pattern) /some/other/path/than/this I can figure it out to the point where it will only recurse into normal directories once it has checked to see if there are any symlinks...however, I can't figure out how to get it to parse directories and symlinks.
Re: Help with File::Find
by SamQi (Beadle) on Sep 18, 2000 at 22:37 UTC
    The first one is a typo...it's supposed to say "Don't recurse *certain* directories" As in recurse most, but ignore these.

      To stop recursion set variable $File::Find::prune in true value (e.g. $File::Find::prune = 1) when you will in *certain* directory

      -- brother ab

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://32997]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-28 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found