2

[Perl] Finding Files, The Fun And Elegant Way


Posted by Artem Russakovskii on April 8th, 2009 in Awesomeness, Linux, Perl, Programming, Tutorials
Share

Updated: October 6th, 2009

2 Responses to “[Perl] Finding Files, The Fun And Elegant Way”

    2 Comments:
  1. Andy Lester says:

    Glad you dig the File::Find::Rule, but I've always found it to be a pain to use. Rather than having to use plugin filters, I'd rather just write my own if necessary. So I wrote File::Next.

    use File::Next;

    my $iter =
    File::Next::files( {
    file_filter => sub { /\.pl$/ },
    descend_filter => sub { $_ ne '.svn' },
    }, '.', '../SomeDir' );

    while ( my $file = $iter->() ) {
    print "$file\n";
    }

    Like your previous example, that finds all .pl files under . and ../SomeDir, without looking into the .svn directories.

  2. Shlomi Fish says:

    I should note that I recently began work on File-Find-Object-Rule, which is a port of File-Find-Rule to File-Find-Object. This would eventually allow F-F-O-R to overcome some of File::Find::Rule inherent limitations, which are caused due to its reliance on File::Find.

    The interface of F-F-Object-Rule still remains pretty much backwards compatible to that of F-F-Rule, but some stuff (like "->start()" and "->match()") have become much saner.

Leave a Reply

Connect with Facebook