Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

traversing directory's

by astanley (Beadle)
on Mar 12, 2001 at 00:54 UTC ( #63657=perlquestion: print w/replies, xml ) Need Help??

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

Good afternoon everyone, I recently started a project just for grins that will act as a flexible search engine for a web page. In the script I statically provide the top directory to begin searching in and I'm trying to have the script compare the contents of every file under that directory with the user's query and return the matches. It works great for the top level directory but I can't figure the best way to traverse through the rest of the directory's under the top level. I saw a node discussing File::Find but am unsure if that module would perform what I need. Does anyone have any other suggestions? I want the script to be intelligent enough to traverse through as many directory's and levels as it can find rather than setting a static number for it to stop.
Adam

Replies are listed 'Best First'.
Re: traversing directory's
by athomason (Curate) on Mar 12, 2001 at 01:25 UTC
    File::Find actually sounds ideal for what you want, and it will most likely do it better than you could yourself. Typical file-tree depth searchers get hung up on symbolic links if you don't explicitly take them into account. File::Find will handle this and other problems with aplomb. It's also very flexible; just plug in your matching function (wanted() in the docs) and you're up and running. See Corion's review and following thread for additional considerations, and the local copy of the |File::Find doc for how to use it. And of course, there are a boatload of existing nodes around the site (see above posts) relating to the module.
Re: traversing directory's
by aardvark (Pilgrim) on Mar 12, 2001 at 01:21 UTC
    You may want to look here or here or here for starters.

    Get Strong Together!!

Re: traversing directory's
by Chady (Priest) on Mar 12, 2001 at 01:22 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2021-12-03 10:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (28 votes). Check out past polls.

    Notices?