NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
File::Find (Score:2)
While everybody's hyping up their own favourite File::Find [cpan.org] replacement, I just want to chime in and say that, for a lot of the replacement modules, I just like File::Find better. In particular, File::find::Rule [cpan.org], which I find just incomprehensible, and horrible.
I wonder if many of the "problems" people see for File::Find are actually problems. So it uses global variables as fake parameters... but they're dynamically limited in scope to (the immediate surroundings of) the callback sub. So I don't mind ist so much. The situation is actually very much alike to the keyword :)
thisin plenty of OO languages. Besides, File::Next [cpan.org] does the same.But you do have to do it the proper way: use an anonymous sub, not a reference to a global function. That way, you end up with a closure, instead of something that depends on global variables (not File::Find's own global variables, but yours).
Do
Not
Reply to This
Re: (Score:1)
The point is,
push @files, $File::Find::nameis what everyone does. So at best it’s unnecessary noise and the module should do that automatically.However, the reason everyone does that is because performing complex work from within a callback is a pain. State machines are no fun to write. An iterator interface is much nicer to work with when you have something complex to do, and just as easy to use when you really just want to collect the file names. It’s much friendlier to use in programs that