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

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.
  • Interface (Score:2, Informative)

    Yeah, I thought about doing a "nice" version of File::Find myself. I wanted to tie in a few things as well - the ability to get structured data as well as lists from it, and to cache data.

    I'm not sure I like the stream-y interface you've got here - powerful, but violates the KISS principle which makes File::Find such a pain in the arse to use at the moment. I'd pictured more of a hash-based interface, but I hadn't thought of options so much (but I guess they could be done either by regexps or arrays).


    • It was almost the same thing I came up when thinking about it.

      I'd like to see something like this:

      my @files = find('/tmp', { maxdepth => 10, mindepth => 5, name => qr/\.*\.c$/ });

      (Which I btw already have working in a small example I hacked together.) I really like your idea of using arrays for alternation, but how do you decide wheter to AND or OR? (AND doesn't make much sense in your example though).

      Instead of returning the files I'd also consider an 'exec' like option that took a s
      • my @files = find('/tmp', { maxdepth => 10, mindepth => 5, name => qr/\.*\.c$/ });

        Warning: hashes found not to have a predictable order. Evaluating the rules in a known order can have a huge effect on efficiency. Please look at rafael's "Good example for 'or'" comment, if the exec happened first you'd really feel a hit from it just shortcutting that happens at name('*.pl').

        (Which I btw already have working in a small example I hacked together.)

        Please, don't let me stop you releasing your

        • I thunk it out a bit more, and now it's possible to do this:
          # extract from the test suite
          # procedural form of the prune CVS demo
          use File::Find::Ruleset 'find_ruleset';
          $f = find_ruleset(or => [ find_ruleset( directory =>
                                                  name      => 'CVS',
                                                  prune     =>
                                                  discard   => ),
                                    find_ruleset() ]);
          my @things = $f->find('.');

          Yes, it's still calling a method but if don't ever want to see an arrow you can do that too, at a slight performance cost:

          my @mp3s = find_ruleset( file => name => '*.mp3', find => '.');