NAME

subst - Greple module for text search and substitution

VERSION

Version 2.13

SYNOPSIS

greple -Msubst --dict dictionary [ options ]

--dict      dictionary file
--dictdata  dictionary data

--check=[ng,ok,any,outstand,all]
--select=N
--linefold
--stat
--with-stat
--stat-style=[default,dict]
--diff
--diffcmd command
--replace
--create
--[no-]warn-overlap
--[no-]warn-include

DESCRIPTION

This greple module supports check and substitution of text file using a dictionary file.

Dictionary file is given by --dict option and contains pattern and expected string pairs.

greple -Msubst --dict DICT

If the dictionary file contains following data:

colou?r      color
cent(er|re)  center

Then above command find the first pattern which does not match the second string, that is "colour" and "centre" in this case.

Field "//" in dictionary file is ignored, so this file can be written like this:

colou?r      //  color
cent(er|re)  //  center

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 command line.

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

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, put the longer pattern in front.

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 module. It sets option --light-screen or --dark-screen depending on the terminal on which the command run, or BRIGHTNESS environment variable.

Some terminals (eg: "Apple_Terminal" or "iTerm") are detected automatically and no action is required. Otherwise set BRIGHTNESS environment to 0 (black) to 100 (white) digit depending on terminal background color.

OPTIONS

DICTIONARY

This module includes example dictionaries. They are installed share directory and accessed by --exdict option.

greple -Msubst --exdict jtca-katakana-guide-3.dict

INSTALL

CPANMINUS

$ cpanm App::Greple::subst
or
$ curl -sL http://cpanmin.us | perl - App::Greple::subst

SEE ALSO

https://github.com/kaz-utashiro/greple

https://github.com/kaz-utashiro/greple-subst

https://www.jtca.org/standardization/katakana_guide_3_20171222.pdf

https://www.jtf.jp/jp/style_guide/styleguide_top.html, https://www.jtf.jp/jp/style_guide/pdf/jtf_style_guide.pdf

AUTHOR

Kazumasa Utashiro

LICENSE

Copyright (C) 2017-2020 Kazumasa Utashiro.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.