App-Greple
view release on metacpan or search on metacpan
script/greple view on Meta::CPAN
You can also define arbitrary complex blocks by writing module or
script.
greple -Myour_module --block '&your_function' ...
=head2 MATCH AREA CONTROL
Using option C<--inside> and C<--outside>, you can specify the text
area to be matched. Next commands search only in mail header and body
area respectively. In these cases, data block is not changed, so
print lines which contain the pattern in the specified area.
greple --inside '\A(.+\n)+' pattern
greple --outside '\A(.+\n)+' pattern
Option C<--inside>/C<--outside> can be used repeatedly to enhance the
area to be matched. There are similar options
C<--include>/C<--exclude>, but they are used to trim down the area.
These four options also take user defined function and any complex
region can be used.
=head2 MODULE AND CUSTOMIZATION
User can define default and original options in F<~/.greplerc>. Next
example enables colored output always, and define new option using
macro processing.
option default --color=always
define :re1 complex-regex-1
define :re2 complex-regex-2
define :re3 complex-regex-3
option --newopt --inside :re1 --exclude :re2 --re :re3
Specific set of function and option interface can be implemented as
module. Modules are invoked by C<-M> option immediately after command
name.
For example, B<greple> does not have recursive search option, but it
can be implemented by C<--readlist> option which accepts target file
list from standard input. Using B<find> module, it can be written
like this:
greple -Mfind . -type f -- pattern
Also B<dig> module implements more complex search. It can be used as
simple as this:
greple -Mdig pattern --dig .
but this command is finally translated into following option list.
greple -Mfind . ( -name .git -o -name .svn -o -name RCS ) -prune -o
-type f ! -name .* ! -name *,v ! -name *~
! -iname *.jpg ! -iname *.jpeg ! -iname *.gif ! -iname *.png
! -iname *.tar ! -iname *.tbz ! -iname *.tgz ! -iname *.pdf
-print -- pattern
=head2 INCLUDED MODULES
The distribution includes some sample modules. Read document in each
module for detail. You can read the document by C<--man> option or
L<perldoc> command.
greple -Mdig --man
perldoc App::Greple::dig
When it does not work, use C<perldoc App::Greple::dig>.
=over 7
=item B<colors>
Color variation module.
See L<App::Greple::colors>.
=item B<find>
Module to use L<find(1)> command to help recursive search.
See L<App::Greple::find>.
=item B<dig>
Module for recursive search using B<find> module. Defines C<--dig>,
C<--git> and C<--git-r> options. See L<App::Greple::dig>.
=item B<pgp>
Module to search B<pgp> files.
See L<App::Greple::pgp>.
=item B<select>
Module to select files.
See L<App::Greple::select>.
=item B<perl>
Sample module to search from perl source files.
See L<App::Greple::perl>.
=back
Other modules are available at CPAN, or git repository
L<https://github.com/kaz-utashiro/>.
=head1 OPTIONS
=head2 PATTERNS
script/greple view on Meta::CPAN
#option --comment --inside :comment:
#option --code --outside :pod:|:comment:
option --pod --inside '&pod'
option --comment --inside '&comment'
option --code --outside '&podcomment'
You can use the module like this:
greple -Mperl --pod default greple
greple -Mperl --colorful --code --comment --pod default greple
If special subroutine C<initialize()> and C<finalize()> are defined in
the module, they are called at the beginning with
L<Getopt::EX::Module> object as a first argument. Second argument is
the reference to C<@ARGV>, and you can modify actual C<@ARGV> using
it. See L<App::Greple::find> module as an example.
Calling sequence is like this. See L<Getopt::EX::Module> for detail.
1) Call initialize()
2) Call function given in -Mmod::func() style
3) Call finalize()
=head1 HISTORY
Most capability of B<greple> is derived from B<mg> command, which has
been developing from early 1990's by the same author. Because modern
standard B<grep> family command becomes to have similar capabilities,
it is a time to clean up entire functionalities, totally remodel the
option interfaces, and change the command name. (2013.11)
=head1 SEE ALSO
L<grep(1)>, L<perl(1)>
L<App::Greple>, L<App::Greple::Grep>
L<https://github.com/kaz-utashiro/greple>
L<Getopt::EX>, L<https://github.com/kaz-utashiro/Getopt-EX>
=head1 AUTHOR
Kazumasa Utashiro
=head1 LICENSE
Copyright 1991-2026 Kazumasa Utashiro
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# LocalWords: greple egrep foo baz yabba dabba doo ascii greplerc
# LocalWords: regex readlist iname jpg jpeg gif png tbz tgz pdf RGB
# LocalWords: perlre fgrep grep perl joinby KATAKANA InKatakana utf
# LocalWords: nonewline filestyle linestyle chdir mtime nocolor jis
# LocalWords: STDOUT colormap Cyan BLOCKEND LESSANSIENDCHARS setuid
# LocalWords: sprintf regioncolor uniqcolor ansicolor nocolorful jp
# LocalWords: struct sockaddr blockend icode euc shiftjis sjis zcat
# LocalWords: ocode gunzip gpg FILELABEL substr eval misc unicode
# LocalWords: GREPLEOPTS shellwords Katakana builtin pgp autoload
# LocalWords: ENV App ARGV mg Kazumasa Utashiro github colorindex
# LocalWords: matchcount gzipped stdin func CPANMINUS cpanm kana
( run in 0.868 second using v1.01-cache-2.11-cpan-df04353d9ac )