in reply to Descending a directory tree, returning a list of files

Hi, Why not use use File::Find::Rule to get the list of files? Here's how I get a list of XML files in all sub-directory starting from the current location:
use File::Find::Rule; my $xml_finder = File::Find::Rule->new()->name(qr/(.*?)\.xml$/i)->star +t("."); while (my $file = $xml_finder->match() ) { # Do whatever you want with your file name }
I hope this helps!

Replies are listed 'Best First'.
Re^2: Descending a directory tree, returning a list of files
by locked_user sundialsvc4 (Abbot) on Jun 09, 2015 at 22:06 UTC

    Definitely agree ... “file finders” (“directory tree walkers”) are the way to go, and there are quite a few good ones in CPAN.   There’s just no point in doing such a mundane chore “by hand.”

      There’s just no point in doing such a mundane chore “by hand.”

      Unless you need to do it "by hand" because the modules on CPAN don't do what you need to do. Perhaps I missed it, but I didn't find any of the "file finders" modules (as you called them) that would handle long file paths (>260 characters) in Windows. Looking at possibly using Win32::LongPath to roll my own code to search through a Windows filesystem and handle the long path names.

      Until I hit this long path issue, I probably would have agreed with what you said.