in reply to File:find tutorial/introduction

I think to get "(a reference to) a hash that can describe the file", you have to look at Path::Class->stat, which uses File::stat. Otherwise, have a look at the plain stat call to find information about a file. Path::Class also has Path::Class::Iterator, which tries to be like File::Find. The basic skeleton for File::Find which I use is:

use File::Find; my @found; find(sub { push @found, $File::Find::name; }, @directories); ...

This has the disadvantage of first collecting all files instead of processing them as they become available, but it has the advantage of a very simple callback.

Replies are listed 'Best First'.
Re^2: File:find tutorial/introduction
by ikegami (Patriarch) on Apr 12, 2010 at 19:49 UTC

    but it has the advantage of a very simple callback.

    I wouldn't call
    my @found; find(sub { push @found, $File::Find::name; }, @directories); for (@found) { next if !check($_); ... }
    simpler (or more complex) than
    my @found; find(sub { push @found, $File::Find::name if check($File::Find::name); + }, @directories); for (@found) { ... }

    The disadvantage of the former approach is that you only have access to the fully qualified name without doing extra work. If you think that's not an issue, you might as well use cleaner File::Find::Rule.

    Update: Added "not" in "If you think that's not an issue". Oops!