I've used File::Find::Rule with success. That said, I like File::Next's nice clean interface.<div><br></div><div>Completely OT: zsh has a builtin globbing operator, **, that means "this directory and below". For example,</div>
<div><br></div><div> find . -name "file*" -print</div><div><br></div><div>would look like the following in zsh land:</div><div><br></div><div> ls **/file*<br><br></div><div>And any command works on the file lists, ls is just the tip of the iceberg. I <3 my new shell.</div>
<div><br><div class="gmail_quote">2010/2/18 Tom Keller <span dir="ltr"><<a href="mailto:kellert@ohsu.edu">kellert@ohsu.edu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word">Summary for modules to traverse a directory tree: <div>0. q(don't roll your own. ... I know that, just needed the exercise.)</div><div>1. File::Next</div><div>2. File::Fu</div><div>3. File::Find::Object</div>
<div>4. File::Finder</div><div>5. File::Find</div><div><br></div><div>thanks,<br><div>
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Verdana;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Verdana;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Verdana;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Verdana;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Verdana;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Verdana;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:Helvetica">
<span style="font-family:Helvetica">Tom</span></div><div style="font-family:Helvetica"><span style="font-family:Helvetica"><a href="mailto:kellert@ohsu.edu" target="_blank">kellert@ohsu.edu</a></span></div><div style="font-family:Helvetica">
<span style="font-family:Helvetica">503-494-2442</span></div></span></span></div></span></div></span><br></div></span><br></div></span><br></div></span><br></div></span><br></span><br>
</div>
<br><div><div>On Feb 18, 2010, at 11:40 AM, Eric Wilhelm wrote:</div><br><blockquote type="cite"><div># from Tom Keller<br># on Thursday 18 February 2010 11:04:<br><br><blockquote type="cite">I need to be able to process files within a directory tree.<br>
</blockquote><br>This will give you all of the files and directories under $topdir:<br><br> my @paths = File::Fu->dir($topdir)->find(sub{1});<br><br>If your matcher sub returns true, the file is returned. So for only the <br>
files:<br><br> my @files = File::Fu->dir($topdir)->find(sub{$_->is_file});<br><br>The filenames returned are File::Fu::File objects relative to wherever <br>$topdir is relative to (i.e. absolute if $topdir is absolute.)<br>
<br>If you want an iterator instead of one big list, you can use the <br>finder() method.<br><br> my $iter = File::Fu->dir($topdir)->finder(sub{1});<br><br> while(defined(my $path = $iter->())) {<br> $path or next;<br>
do_something_with($path);<br> }<br><br><a href="http://search.cpan.org/~ewilhelm/File-Fu-v0.0.6/lib/File/Fu/Dir.pm#finder" target="_blank">http://search.cpan.org/~ewilhelm/File-Fu-v0.0.6/lib/File/Fu/Dir.pm#finder</a><br>
<br>There is currently some better documentation for find(), finder(), and <br>the knob in my svn trunk:<br><br> <a href="http://svn.scratchcomputing.com/File-Fu/trunk/lib/File/Fu/Dir.pm" target="_blank">http://svn.scratchcomputing.com/File-Fu/trunk/lib/File/Fu/Dir.pm</a><br>
<br>--Eric<br>-- <br>Issues of control, repair, improvement, cost, or just plain<br>understandability all come down strongly in favor of open source<br>solutions to complex problems of any sort.<br>--Robert G. Brown<br>---------------------------------------------------<br>
<a href="http://scratchcomputing.com" target="_blank">http://scratchcomputing.com</a><br>---------------------------------------------------<br>_______________________________________________<br>Pdx-pm-list mailing list<br>
<a href="mailto:Pdx-pm-list@pm.org" target="_blank">Pdx-pm-list@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/pdx-pm-list" target="_blank">http://mail.pm.org/mailman/listinfo/pdx-pm-list</a><br></div></blockquote>
</div><br></div></div><br>_______________________________________________<br>
Pdx-pm-list mailing list<br>
<a href="mailto:Pdx-pm-list@pm.org">Pdx-pm-list@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/pdx-pm-list" target="_blank">http://mail.pm.org/mailman/listinfo/pdx-pm-list</a><br></blockquote></div><br></div>