The following module was proposed for inclusion in the Module List:
modid: Dir::Iterate
DSLIP: Rdpfp
description: map/grep-style directory traversal
userid: BRENTDAX (Brent Dax)
chapterid: 10 (File_Names_Systems_Locking)
communities:
similar:
File::Find
rationale:
Dir::Iterate is a vastly simplified functional wrapper around
File::Find. It tends to make directory tree traversal a simple
iterative affair. Since writing it a few years ago, I've used it on
several occasions for some very different scripts; I was surprised
to learn I'd never uploaded it to CPAN.
Dir::Iterate implements two functions, C<mapdir> and C<grepdir>.
These are similar to the C<map> and C<grep> built-ins, except that
they take a list of directory names and call the specified
subroutine with the names of files (recursively) in those
directories. C<mapdir> returns the results from each sub call;
C<grepdir>returns all paths for which the sub returned true.
A surprisingly wide range of directory traversal operations can be
expressed very easily this way, without the strange call patterns or
level of complexity seen in File::Find. For instance, a couple weeks
ago I wrote a short script to increment the build numbers in Xcode
projects, which included this line:
for my $plist_file(grepdir { /-Info.plist$/ } '.') {
This was a ten-line script, but I've used it just as effectively in
a thousand-line file synchronization system. I figured it was useful
enough to share with the public.
enteredby: BRENTDAX (Brent Dax)
enteredon: Wed Sep 12 09:12:15 2012 GMT
The resulting entry would be:
Dir::
::Iterate Rdpfp map/grep-style directory traversal BRENTDAX
Thanks for registering,
--
The PAUSE
PS: The following links are only valid for module list maintainers:
Registration form with editing capabilities:
https://pause.perl.org/pause/authenquery?ACTION=add_mod&USERID=0da00000_f8e876fa0ad2feb4&SUBMIT_pause99_add_mod_preview=1
Immediate (one click) registration:
https://pause.perl.org/pause/authenquery?ACTION=add_mod&USERID=0da00000_f8e876fa0ad2feb4&SUBMIT_pause99_add_mod_insertit=1
Peek at the current permissions:
https://pause.perl.org/pause/authenquery?pause99_peek_perms_by=me&pause99_peek_perms_query=Dir%3A%3AIterate