Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

merlyn (47)

AOL IM: realmerlyn (Add Buddy, Send Message)
Yahoo! ID: realmerlyn (Add User, Send Message)

See my home page [].

Journal of merlyn (47)

Wednesday December 17, 2003
12:11 PM

File::Finder 0.01 released

[ #16392 ]
My first "real" module is now on its way around the world to a CPAN mirror near everyone. Based a bit on how cool File::Find::Rule is, but with a syntax that more closely mimics find, including precendence rules for AND, OR, NOT, and parens. Yes Parens. The cleverest part is the one-pass execution engine that runs down the list of coderefs and meta information to proper handle the nested parens. You shoulda seen all the notes I was writing on the 3.5 state table-transitions based on tests failing or parens ending.

Pick up the docs at For some reason, typing File::Finder in the search box doesn't pull it up at all. Comments welcome.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Looks Nice (Score:3, Insightful)

    by Ovid (2709) on 2003.12.17 12:46 (#26640) Homepage Journal

    Hmm ... seems like an awful lot of duplicated code for checking the file status. Five subs are identical, so I deleted them.

    package File::Finder::Steps;

    use constant OFFSET => qr/^(\+|-|)(.*)/;

    my %status = (
        links => '(stat(_))[3]',
        inum  => '(stat(_))[1]',
        atime => 'int(-A _)',
        mtime => 'int(-M _)',
        ctime => 'int(-C _)',

    while (my ($sub,$op) = each %status) {
        eval <<"    END_SUB";
        sub $sub {
            my \$self = shift;
            my (\$prefix, \$n) = shift =~ OFFSET;

            return sub {
              _n(\$prefix, \$n, $op);

    Passes quite nicely, though not every would care for that :)

    • Heh. Earlier today, I read Schwern's paper on accessors and closures []. Is it me, or is there more than some similarity in the problem statement?

      # And then eval() a new subroutine for each of them.
      foreach my $accessor (@Accessors) {
          eval qq{
              sub $accessor {
                  my(\$self) = shift;
                  if( \@_ ) {
                      my \$data = shift;

      • Yeah, this is a technique I use a lot, though really I should have done this:

        my %status = (
          links => sub { (stat(_))[3] },
          inum  => sub { (stat(_))[1] },
          atime => sub { int(-A _) },
          mtime => sub { int(-M _) },
          ctime => sub { int(-C _) },

        while (my ($function,$op) = each %status) {
          no strict 'refs';
          *$function = sub {
            my $self = shift;
            my ($prefix, $n) = shift =~ OFFSET;

            return sub {

  • Pick up the docs at For some reason, typing File::Finder in the search box doesn't pull it up at all.
    It does now. Remember, PAUSE, the CPAN, and are only loosely coupled, and it takes time for changes to filter through from one to t'other.