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.
  • Random thoughts :

    NewFind->file() instead of ->type('file')
    NewFind->name( '*.mp3', '*.ogg' ) to get a shorter 'or' condition (in this case, can be written as NewFind->name( qr/\.(mp3|ogg)$/ ))
    Provide an ->exec( \&command ) hook, similar to the -exec option to find(1) : i.e., gets the pathname as its only parameter, returns true or false.
    Think about -prune and finddepth.

    • NewFind->file() instead of ->type('file')

      Yes, I was being very literal in a transliteration of a find(1) example, apart from making it longer of course.

      NewFind->name( '*.mp3', '*.ogg' ) to get a shorter 'or' condition (in this case, can be written as NewFind->name( qr/\.(mp3|ogg)$/ ))

      I like both of those.

      I still think there's need for a form of or. I just can't think of a good example right now.

      • my $finder = NewFind->or(
          NewFind->name( '*.pl' ),
          NewFind->exec( sub {
            my $file = shift; my $fh;
            if (open $fh, $file) {
              my $shebang = <$fh>;
              close $fh;
              return $shebang =~ /^#!.*\bperl/;
            }
            return 0;
          } ),
        );
      • You still need an explicit or when your conditions are not on the same variable. The form shown here works for var == val1 or val2 but not var1 == val1 or var2 == val2. For example, file is greater than 500M or older than 3 days.

        --
        J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
        • I'm sorry, I don't follow. var == val1 or val2 seems to be like name('*.mp3', '*.ogg') and var1 == val1 or var2 == val2 is:
          # files greater than 500M or older than 3 days
          F->or( F->size( '>500M' ),
                 F->age ( '> 3 days' )
               );

          As in rafaels "Good example for 'or'" post

          • Yes, you followed what I was saying. I was giving an example where you have to have an explicit F->or method.

            --
            J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
    • My thoughts about finddepth are to ignore it, as it confuses me.

      Can I get a quick show of hands as to whether people will really miss this? If so then I'll find a way to make it work.