Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

RE: recurse directories?

by Anonymous Monk
on Mar 13, 2000 at 00:37 UTC ( [id://5267]=note: print w/replies, xml ) Need Help??


in reply to recurse directories?

You could also try the File::Recurse module on CPAN. Alternatively, if you're on a Linux system, a faster way of finding rare files is by backquoting, e.g. $location = `locate $name`; It's a hell of a lot faster than traversing the file tree manually as it uses an updated database of file locations rather than tromping all over the file system. (remember to update the file database with 'updatedb' as root before doing intensive searches. If on WinWhatever, ignore the above. From the File::Recurse docs: The File::Recurse module is designed for performing an operation on a tree of directories and files. The basic usage is simmilar to the find.pl library. Once one uses the File::Recurse module, you need only call the recurse function in order to perform recursive directory operations. The function takes two parameters a function reference and a directory. The function referenced by the first parameter should expect to take one parameter: the full path to the file currently being operated on. This function is called once for every file and directory under the directory named by the second parameter. For example: recurse(\&func, "/"); would start at the top level of the filesystem and call "func" for every file and directory found (not including "/"). Perl allows a second form of calling this function which can be useful for situations where you want to do something simple in the function. In these cases, you can define an anonymous function by using braces like so: recurse {print $_[0]} "/"; This would print every file and directory in the filesystem. However, as an added convenience you can access the pathname in the variable $_. So the above could be r

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found