App-Greple
view release on metacpan or search on metacpan
`.greplerc` file or by module option.
- **--include**=_pattern_
- **--exclude**=_pattern_
- **--include**=_&function_
- **--exclude**=_&function_
`--include`/`--exclude` option behave exactly same as
`--inside`/`--outside` when used alone.
When used in combination, `--include`/`--exclude` are mixed in AND
manner, while `--inside`/`--outside` are in OR.
Thus, in the next example, first line prints all matches, and second
does none.
greple --inside PATTERN --outside PATTERN
greple --include PATTERN --exclude PATTERN
You can make up desired matches using `--inside`/`--outside` option,
then remove unnecessary part by `--include`/`--exclude`
- **--strict**
Limit the match area strictly.
By default, `--block`, `--inside`/`outside`,
`--include`/`--exclude` option allows partial match within the
specified area. For instance,
greple --inside and command
matches pattern `command` because the part of matched string is
included in specified inside-area. Partial match fails when option
`--strict` provided, and longer string never matches within shorter
area.
Interestingly enough, above example
greple --include PATTERN --exclude PATTERN
produces output, as a matter of fact. Think of the situation
searching, say, `' PATTERN '` with this condition. Matched area
includes surrounding spaces, and satisfies both conditions partially.
This match does not occur when option `--strict` is given, either.
**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.
( run in 3.368 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )