[Pdx-pm] recursive IO::Dir alternatives

Joshua Keroes jkeroes at gmail.com
Thu Feb 18 13:24:01 PST 2010


I've used File::Find::Rule with success. That said, I like File::Next's nice
clean interface.

Completely OT: zsh has a builtin globbing operator, **, that means "this
directory and below". For example,

  find . -name "file*" -print

would look like the following in zsh land:

  ls **/file*

And any command works on the file lists, ls is just the tip of the iceberg.
I <3 my new shell.

2010/2/18 Tom Keller <kellert at ohsu.edu>

> Summary for modules to traverse a directory tree:
> 0. q(don't roll your own. ... I know that, just needed the exercise.)
> 1. File::Next
> 2. File::Fu
> 3. File::Find::Object
> 4. File::Finder
> 5. File::Find
>
> thanks,
>     Tom
> kellert at ohsu.edu
> 503-494-2442
>
>
>
>
>
>
>
> On Feb 18, 2010, at 11:40 AM, Eric Wilhelm wrote:
>
> # from Tom Keller
> # on Thursday 18 February 2010 11:04:
>
> I need to be able to process files within a directory tree.
>
>
> This will give you all of the files and directories under $topdir:
>
>  my @paths = File::Fu->dir($topdir)->find(sub{1});
>
> If your matcher sub returns true, the file is returned.  So for only the
> files:
>
>  my @files = File::Fu->dir($topdir)->find(sub{$_->is_file});
>
> The filenames returned are File::Fu::File objects relative to wherever
> $topdir is relative to (i.e. absolute if $topdir is absolute.)
>
> If you want an iterator instead of one big list, you can use the
> finder() method.
>
>  my $iter = File::Fu->dir($topdir)->finder(sub{1});
>
>  while(defined(my $path = $iter->())) {
>    $path or next;
>    do_something_with($path);
>  }
>
> http://search.cpan.org/~ewilhelm/File-Fu-v0.0.6/lib/File/Fu/Dir.pm#finder
>
> There is currently some better documentation for find(), finder(), and
> the knob in my svn trunk:
>
>  http://svn.scratchcomputing.com/File-Fu/trunk/lib/File/Fu/Dir.pm
>
> --Eric
> --
> Issues of control, repair, improvement, cost, or just plain
> understandability all come down strongly in favor of open source
> solutions to complex problems of any sort.
> --Robert G. Brown
> ---------------------------------------------------
>    http://scratchcomputing.com
> ---------------------------------------------------
> _______________________________________________
> Pdx-pm-list mailing list
> Pdx-pm-list at pm.org
> http://mail.pm.org/mailman/listinfo/pdx-pm-list
>
>
>
> _______________________________________________
> Pdx-pm-list mailing list
> Pdx-pm-list at pm.org
> http://mail.pm.org/mailman/listinfo/pdx-pm-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/pdx-pm-list/attachments/20100218/be53bd23/attachment.html>


More information about the Pdx-pm-list mailing list