Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I consider the slowness of File::Find and its derivatives to be legendary (based on benchmarks I did here and here). While some of the derivatives offer different API's that might feel more sensible to you depending on what your background is, none of them seem to escape the basic problem of being relatively quite slow on relatively large directory trees.

That's why I tend to favor using the standard "find" utility from within the perl script, the best idiom being something like:

my $path = "/whatever/path"; { local $/ = "\0"; open( FIND, "find $path -print0 |" ); while (<FIND>) { chomp; # do something with this name... } }
with other options added as needed on the "find" command line. Some might think this is "ugly" because it's not pure Perl, and some might think the "find" command is ugly in its own way, but if you've read the man page and know how to use it, it works, it's pretty simple, and nothing else is faster (and some others do seem to agree that "find"-based usage is not as ugly as File::Find).

Since there are Windows ports of this basic utility, the only barrier to using it would be boneheaded policy constraints against installing such apps on Windows machines. For *n*x users, it seems like a no-brainer.


In reply to Re: How do you make File::Find a bit less ugly? by graff
in thread How do you make File::Find a bit less ugly? by qazwart

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 browsing the Monastery: (10)
As of 2024-04-19 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found