Stories
Slash Boxes
Comments
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.
 Full
 Abbreviated
 Hidden
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).

    my

    • I'm not sure I like the stream-y interface you've got here - powerful,

      I wasn't either, hence the posting, but then I saw Rafael's beautiful "Good example for 'or'" for which powerful is certainly one of the words I'd use.

      By stream-y I assume you mean the chaining of method calls? If you don't like it you can always do it in longhand:

      my $f = NewFind->new();
      $f->name( '*.mp3', '*.ogg' );
      $f->size( '<10000' );
      my @potayto = $f->find('.');

      my @potahto = NewFind->name( '*.mp3', '*.ogg' )

      • The notation of chaining method calls like that is an unfamiliar one to me at least (see, told you I was crap), and probably to the target audience of the module (viz. those who find all those icky callbacks in File::Find too tricky).

        As for the tree, I envisaged some kind of structure depending on what parameters you pass to the find involving some quantities of stat()ing etc., thusly:

        $VAR1 = {
              name => '.',
              path => '.',
              abspath => '/home/richardc',
              type => 'directory',
              children => [
                    {
                      name => 'music',
                      path => './music',
                      abspath => '/home/richardc/music',
                      type => 'directory',
                      children => [
                            {
                              name => 'S Club 7 - Party.mp3',
                              path => './music/S Club 7 - Party.mp3',
                              abspath => '/home/richardc/music/S Club 7 - Party.mp3',
                              type => 'file'
                            }
                                  ]
                    },
                    {
                      name => 'Procul Harum - A Whiter Shade of Pale.ogg',
                      path => './Procul Harum - A Whiter Shade of Pale.ogg',
                      abspath => '/home/richardc/music/Procul Harum - A Whiter Shade of Pale.ogg',
                      type => 'file'
                    }
                          ]
            }

        Basically enough information to reconstruct the file list but letting you walk the tree structure.