File::Find::Match::Util - Some exportable utility functions for writing rulesets.
use File::Find::Match::Util qw( filename ); $pred = filename('foobar.pl'); $pred->('foobar.pl') == 1; $pred->('baz/foobar.pl') == 1; $pred->('baz/bar/foobar.pl') == 1; $pred->('bazquux.pl') == 0; $pred = ext('pm'); $pred->('foo.pm') == 1; $pred->('foo.png') == 0; $pred->('foo.pmg') == 0; $pred = wildcard('*.pod'); $pred->('foo.pod') == 1; $pred->('foo/bar.pod') == 1; $pred->('foo/.pod') == 1; $pred->('Spoon') == 0;
This provides a few handy functions which create predicates for File::Find::Match.
The following functions are available for export.
This function returns a subroutine reference, which takes one argument $file and returns true if File::Basename::basename($file) eq $basename, false otherwise. See File::Basename for details.
File::Basename::basename($file) eq $basename
File::Basename
Essentially, filename('foobar') is equivalent to:
filename('foobar')
sub { File::Basename::basename($_[0]) eq 'foobar' }
This function returns a subroutine reference, which takes argument $file and returns true if it ends with ".$extension".
".$extension"
Perform shell-like wildcard matching. Currently only * is supported. * is exactly equivelent to regexp .+, which is possibly incorrect.
Patches are welcome.
None by default.
"filename($basename)", "ext($extension)", "wildcard($pattern)".
None known. Bug reports are welcome.
Please use the CPAN bug ticketing system at http://rt.cpan.org/. You can also mail bugs, fixes and enhancements to <bug-file-find-match at rt.cpan.org>.
<bug-file-find-match
rt.cpan.org>
Thanks to Andy Wardly for the name, and the Template Toolkit list for inspiration.
Dylan William Hardison <dhardison@cpan.org>
http://dylan.hardison.net/
File::Find::Match, File::Find, perl(1).
Copyright (C) 2004 Dylan William Hardison. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install File::Find::Match, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Find::Match
CPAN shell
perl -MCPAN -e shell install File::Find::Match
For more information on module installation, please visit the detailed CPAN module installation guide.