Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How do you make File::Find a bit less ugly?

by graff (Chancellor)
on Jun 13, 2006 at 23:43 UTC ( [id://555151]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to How do you make File::Find a bit less ugly?

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.

Replies are listed 'Best First'.
Re^2: How do you make File::Find a bit less ugly?
by bart (Canon) on Jun 14, 2006 at 04:06 UTC
    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.
    I disagree.

    First: These ports tend to use Unix-like syntax for their file paths. Often they're having difficulties with colons or with backslashes as path separators.

    Second: if you want to use the full power of the tool, or even get moderately fluent, there's no command line utility so hard to get used to as find.

      if you want to use the full power of the tool, or even get moderately fluent, there's no command line utility so hard to get used to as find.

      For me, it is Maypole-the-magic. Oh, "comand line utility" would be sed with multiple backslashing-the-backslash version ... then ... i just pull out awk|perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://555151]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.