App-Greple

 view release on metacpan or  search on metacpan

lib/App/Greple/select.pm  view on Meta::CPAN

=head1 NAME

select - Greple module to select files

=head1 SYNOPSIS

greple -Mdig -Mselect ... --dig .

  FILENAME
    --suffix           file suffixes
    --select-name      regex match for file name
    --select-path      regex match for file path
    --x-suffix         exclusive version of --suffix
    --x-select-name    exclusive version of --select-name
    --x-select-path    exclusive version of --select-path

  DATA
    --shebang          included in #! line
    --select-data      regex match for file data
    --select-longer=#  contain lines longer than #
    --x-shebang        exclusive version of --shebang
    --x-select-data    exclusive version of --select-data
    --x-select-longer  exclusive version of --select-longer

=head1 DESCRIPTION

Greple's B<-Mselect> module allows to filter files using their name
and content data.  It is usually supposed to be used along with
B<-Mfind> or B<-Mdig> module.

For example, next command scan files end with C<.pl> and C<.pm> under
current directory.

    greple -Mdig -Mselect --suffix=pl,pm foobar --dig .

This is almost equivalent to the next command using B<--dig> option
with extra conditional expression for B<find> command.

    greple -Mdig foobar --dig . -name '*.p[lm]'

The problems is that the above command does not search perl command
script without suffixes.  Next command looks for both files looking at
C<#!> (shebang) line.

    greple -Mdig -Mselect --suffix=pl,pm --shebang perl foobar --dig .

Generic option B<--select-name>, B<--select-path> and B<--select-data>
take regular expression and works for arbitrary use.

=head2 ORDER and DEFAULT

Besides normal inclusive rules, there is exclusive rules which start
with B<--x-> option name.

As for the order of rules, all exclusive rules are checked first, then
inclusive rules are applied.

When no rules are matched, default action is taken.  If no inclusive
rule exists, it is selected.  Otherwise discarded.

=head1 OPTIONS

=head2 FILENAME

=over 7

=item B<--suffix>=I<xx,yy,zz ...>

Specify one or more file name suffixes connecting by comma (C<,>).
They will be converted to C</\.(xx|yy|zz)$/> expression and compared
to the file name.

=item B<--select-name>=I<regex>

Specify regular expression and it is compared to the file name.  Next
command search Makefiles under any directory.

    greple -Mselect --select-name '^Makefile.*'

=item B<--select-path>=I<regex>

Specify regular expression and it is compared to the file path.

=item B<--x-suffix>=I<xx,yy,zz ...>

=item B<--x-select-name>=I<regex>

=item B<--x-select-path>=I<regex>

These are reverse version of corresponding options.  File is not
selected when matched.

=back

=head2 DATA

=over 7

=item B<--shebang>=I<aa,bb,cc>

This option test if a given string is included in the first line of
the file start with C<#!> (aka shebang) mark.  Multiple names can be



( run in 2.432 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )