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
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Syntactic sugar for less verbosity (Score:2, Interesting)
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.
Re:Syntactic sugar for less verbosity (Score:1)
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.Good example for 'or' (Score:2, Interesting)
NewFind->name( '*.pl' ),
NewFind->exec( sub {
my $file = shift; my $fh;
if (open $fh, $file) {
my $shebang = <$fh>;
close $fh;
return $shebang =~
}
return 0;
} ),
);
Reply to This
Parent