App-Greple-subst

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

string, rather than last two element.  Leading spaces and spaces
before and after `//` are ignored, but all other whitespace is valid.

You can use same file by **greple**'s **-f** option and string after
`//` is ignored as a comment in that case.

    greple -f DICT ...

Option **--dictdata** can be used to provide dictionary data in the
command line.

    greple -Msubst \
           --dictdata $'colou?r color\ncent(er|re) center\n'

Option **--dictpair** can be used to provide raw dictionary entries in
the command line.  In this case, no processing is done regarding
whitespace, comments, or DEFINE expansion.

    greple -Msubst \
           --dictpair 'colou?r' color \
           --dictpair 'cent(er|re)' center

Dictionary entry starting with a sharp sign (`#`) is a comment and
ignored.

## DEFINE

You can define a named regex pattern in the dictionary file using the
Perl's DEFINE syntax:

    (?(DEFINE)(?<name>pattern))

The defined pattern can be referenced in the dictionary entries using
`(?&name)` syntax.

    (?(DEFINE)(?<digit>\d+))
    (?&digit)/(?&digit)/(?&digit)  //  YYYY/MM/DD

You can define multiple patterns and use them in combination.  The
pattern definition must appear before its reference.

## Overlapped pattern

When the matched string is same or shorter than previously matched
string by another pattern, it is simply ignored (**--no-warn-include**
by default).  So, if you have to declare conflicted patterns, place
the longer pattern earlier.

If the matched string overlaps with previously matched string, it is
warned (**--warn-overlap** by default) and ignored.

## Terminal color

This version uses [Getopt::EX::termcolor](https://metacpan.org/pod/Getopt%3A%3AEX%3A%3Atermcolor) module.  It sets option
**--light-screen** or **--dark-screen** depending on the terminal on
which the command run, or **TERM\_BGCOLOR** environment variable.

Some terminals (eg: "Apple\_Terminal" or "iTerm") are detected
automatically and no action is required.  Otherwise set
**TERM\_BGCOLOR** environment to #000000 (black) to #FFFFFF (white)
digit depending on terminal background color.

# OPTIONS

- **--dict**=_file_

    Specify dictionary file.

- **--dictdata**=_data_

    Specify dictionary data by text.

- **--dictpair** _pattern_ _replacement_

    Specify dictionary entry pair.  This option takes two parameters.  The
    first is a pattern and the second is a substitution string.

- **--check**=`outstand`|`ng`|`ok`|`any`|`all`|`none`

    Option **--check** takes argument from `ng`, `ok`, `any`,
    `outstand`, `all` and `none`.

    With default value `outstand`, command will show information about
    both expected and unexpected words only when unexpected word was found
    in the same file.

    With value `ng`, command will show information about unexpected
    words.  With value `ok`, you will get information about expected
    words.  Both with value `any`.

    Value `all` and `none` make sense only when used with **--stat**
    option, and display information about never matched pattern.

- **--select**=_N_

    Select _N_th entry from the dictionary.  Argument is interpreted by
    [Getopt::EX::Numbers](https://metacpan.org/pod/Getopt%3A%3AEX%3A%3ANumbers) module.  Range can be defined like
    **--select**=`1:3,7:9`.  You can get numbers by **--stat** option.

- **--linefold**

    If the target data is folded in the middle of text, use **--linefold**
    option.  It creates regex patterns which matches string spread across
    lines.  Substituted text does not include newline, though.  Because it
    confuses regex behavior somewhat, avoid to use if possible.

- **--stat**
- **--with-stat**

    Print statistical information.  Works with **--check** option.

    Option **--with-stat** print statistics after normal output, while
    **--stat** print only statistics.

- **--stat-style**=`default`|`dict`

    Using **--stat-style=dict** option with **--stat** and **--check=any**,
    you can get dictionary style output for your working document.

- **--stat-item** _item_=\[0,1\]



( run in 0.975 second using v1.01-cache-2.11-cpan-f56aa216473 )