Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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 y


In reply to RE: recurse directories? by Anonymous Monk
in thread recurse directories? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-28 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found