App-Greple
view release on metacpan or search on metacpan
**Related options:**
**--block** (["BLOCKS"](#blocks)),
**--regioncolor** (["COLORS"](#colors)),
**-e**/**-v** (["PATTERNS"](#patterns))
## CHARACTER CODE
- **--icode**=_code_
Target file is assumed to be encoded in utf8 by default. Use this
option to set specific encoding. When handling Japanese text, you may
choose from 7bit-jis (jis), euc-jp or shiftjis (sjis). Multiple code
can be supplied using multiple option or combined code names with
space or comma, then file encoding is guessed from those code sets.
Use encoding name `guess` for automatic recognition from default code
list which is euc-jp and 7bit-jis. Following commands are all
equivalent.
greple --icode=guess ...
greple --icode=euc-jp,7bit-jis ...
greple --icode=euc-jp --icode=7bit-jis ...
Default code set are always included suspect code list. If you have
just one code adding to suspect list, put + mark before the code name.
Next example does automatic code detection from euc-kr, ascii, utf8
and UTF-16/32.
greple --icode=+euc-kr ...
If the string "**binary**" is given as encoding name, no character
encoding is expected and all files are processed as binary data.
- **--ocode**=_code_
Specify output code. Default is utf8.
## FILTER
- **--if**=_filter_, **--if**=_EXP_:_filter_
You can specify filter command which is applied to each file before
search. If only one filter command is specified, it is applied to all
files. If filter information include colon, first field will be perl
expression to check the filename saved in variable $\_. If it
successes, next filter command is pushed.
greple --if=rev perg
greple --if='/\.tar$/:tar tvf -'
If the command doesn't accept standard input as processing data, you
may be able to use special device:
greple --if='nm /dev/stdin' crypt /usr/lib/lib*
Filters for compressed and gzipped file is set by default unless
`--noif` option is given. Default action is like this:
greple --if='s/\.Z$//:zcat' --if='s/\.g?z$//:gunzip -c'
File with `.gpg` suffix is filtered by **gpg** command. In that case,
pass-phrase is asked for each file. If you want to input pass-phrase
only once to find from multiple files, use `-Mpgp` module.
If the filter starts with `&`, perl subroutine is called instead of
external command. You can define the subroutine in `.greplerc` or
modules. **Greple** simply call the subroutine, so it should be
responsible for process control. It may have to use `POSIX::_exit()`
to avoid executing an `END` block on exit or calling destructor on
the object.
- **--noif**
Disable default input filter. Which means compressed files will not
be decompressed automatically.
- **--of**=_filter_
- **--of**=_&func_
Specify output filter which process the output of **greple** command.
Filter command can be specified in multiple times, and they are
invoked for each file to be processed. So next command reset the line
number for each file.
greple --of 'cat -n' string file1 file2 ...
If the filter starts with `&`, perl subroutine is called instead of
external command. You can define the subroutine in `.greplerc` or
modules.
Output filter command is executed only when matched string exists to
avoid invoking many unnecessary processes. No effect for option
`-l` and `-c`.
- **--pf**=_filter_
- **--pf**=_&func_
Similar to `--of` filter but invoked just once and takes care of
entire output from **greple** command.
## RUNTIME FUNCTIONS
- **--begin**=_function_(_..._)
- **--begin**=_function_=_..._
Option `--begin` specify the function executed at the beginning of
each file processing. This _function_ have to be called from **main**
package. So if you define the function in the module package, use the
full package name or export properly.
If the function dies with a message starting with a word "SKIP"
(`/^SKIP/i`), that file is simply skipped. So you can control if the
file is to be processed using the file name or content. To see the
message, use `--warn begin=1` option.
For example, using next function, only perl related files will be
processed.
sub is_perl {
my %arg = @_;
my $name = delete $arg{&FILELABEL} or die;
( run in 1.175 second using v1.01-cache-2.11-cpan-df04353d9ac )