IO::All works too. Here&#39;s some tasty idioms taken from the doc page:<div><br></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Read all the files/directories in a directory:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $io = io(&#39;my/directory/&#39;); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Create new directory object</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @contents = $io&minus;&gt;all; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Get all contents of dir</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @contents = @$io; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Directory as an array</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @contents = values %$io; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Directory as a hash</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; push @contents, $subdir &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # One at a time</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while $subdir = $io&minus;&gt;next;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Print the name and file type for all the contents above:</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;$_ is a &quot; . $_&minus;&gt;type . &quot;\n&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Each element of @contents</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for @contents; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# is an IO::All object!!</div><div><br></div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Print first line of each file:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print $_&minus;&gt;getline &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # getline gets one line</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for io(&#39;dir&#39;)&minus;&gt;all_files; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Files only</div>
<div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Print names of all files/dirs three directories deep:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;$_\n&quot; for $io&minus;&gt;all(3); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Pass in the depth. Default=1</div><div><br></div><div>
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Print names of all files/dirs recursively:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;$_\n&quot; for $io&minus;&gt;all(0); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Zero means all the way down</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;$_\n&quot; for $io&minus;&gt;All; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Capitalized shortcut</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print &quot;$_\n&quot; for $io&minus;&gt;deep&minus;&gt;all; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Another way</div><div><br></div><br><div class="gmail_quote">2010/2/18 Tom Keller <span dir="ltr">&lt;<a href="mailto:kellert@ohsu.edu">kellert@ohsu.edu</a>&gt;</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:&nbsp;<div>0. q(don&#39;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> &nbsp;my @paths = File::Fu-&gt;dir($topdir)-&gt;find(sub{1});<br><br>If your matcher sub returns true, the file is returned. &nbsp;So for only the <br>
files:<br><br> &nbsp;my @files = File::Fu-&gt;dir($topdir)-&gt;find(sub{$_-&gt;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> &nbsp;my $iter = File::Fu-&gt;dir($topdir)-&gt;finder(sub{1});<br><br> &nbsp;while(defined(my $path = $iter-&gt;())) {<br> &nbsp;&nbsp;&nbsp;$path or next;<br>
 &nbsp;&nbsp;&nbsp;do_something_with($path);<br> &nbsp;}<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> &nbsp;<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>
 &nbsp;&nbsp;&nbsp;<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>