App-Greple-subst
view release on metacpan or search on metacpan
docs/subst.pod view on Meta::CPAN
string, rather than last two element. Leading spaces and spaces
before and after C<//> are ignored, but all other whitespace is valid.
You can use same file by B<greple>'s B<-f> option and string after
C<//> is ignored as a comment in that case.
greple -f DICT ...
Option B<--dictdata> can be used to provide dictionary data in the
command line.
greple -Msubst \
--dictdata $'colou?r color\ncent(er|re) center\n'
Option B<--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 (C<#>) is a comment and
ignored.
=head2 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
C<(?&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.
=head2 Overlapped pattern
When the matched string is same or shorter than previously matched
string by another pattern, it is simply ignored (B<--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 (B<--warn-overlap> by default) and ignored.
=head2 Terminal color
This version uses L<Getopt::EX::termcolor> module. It sets option
B<--light-screen> or B<--dark-screen> depending on the terminal on
which the command run, or B<TERM_BGCOLOR> environment variable.
Some terminals (eg: "Apple_Terminal" or "iTerm") are detected
automatically and no action is required. Otherwise set
B<TERM_BGCOLOR> environment to #000000 (black) to #FFFFFF (white)
digit depending on terminal background color.
=head1 OPTIONS
=over 7
=item B<--dict>=I<file>
Specify dictionary file.
=item B<--dictdata>=I<data>
Specify dictionary data by text.
=item B<--dictpair> I<pattern> I<replacement>
Specify dictionary entry pair. This option takes two parameters. The
first is a pattern and the second is a substitution string.
=item B<--check>=C<outstand>|C<ng>|C<ok>|C<any>|C<all>|C<none>
Option B<--check> takes argument from C<ng>, C<ok>, C<any>,
C<outstand>, C<all> and C<none>.
With default value C<outstand>, command will show information about
both expected and unexpected words only when unexpected word was found
in the same file.
With value C<ng>, command will show information about unexpected
words. With value C<ok>, you will get information about expected
words. Both with value C<any>.
Value C<all> and C<none> make sense only when used with B<--stat>
option, and display information about never matched pattern.
=item B<--select>=I<N>
Select I<N>th entry from the dictionary. Argument is interpreted by
L<Getopt::EX::Numbers> module. Range can be defined like
B<--select>=C<1:3,7:9>. You can get numbers by B<--stat> option.
=item B<--linefold>
If the target data is folded in the middle of text, use B<--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.
=item B<--stat>
=item B<--with-stat>
Print statistical information. Works with B<--check> option.
Option B<--with-stat> print statistics after normal output, while
B<--stat> print only statistics.
=item B<--stat-style>=C<default>|C<dict>
Using B<--stat-style=dict> option with B<--stat> and B<--check=any>,
you can get dictionary style output for your working document.
( run in 1.085 second using v1.01-cache-2.11-cpan-f56aa216473 )