App-Greple
view release on metacpan or search on metacpan
greple -pi -e 'cyclic redundancy c\w+' rfc*
greple -o --joinby=' ' -ie 'cyclic redundancy c\w+' rfc*
### find Kanji and not CJKUnifiedIdeographs / æ¼¢åã ãã© CJKUnifiedIdeographs ãããªãæåãæ¢ã
greple --inside='\p{Han}+' '[^\s\p{InCJKUnifiedIdeographs}]'
# This works, but quite slow. Not recommended.
# åããã©ãã§ã¼é
ããããããªãã¨ãã¡ãé§ç®ãã
### guess data encoding / æåã³ã¼ããèªåå¤å®ãã
greple --icode=guess
### specify data encoding / æåã³ã¼ããæå®ãã
greple --icode=euc-jp
greple --icode=shif-jis
### specify guessing code set / èªåå¤å®ããã³ã¼ããæå®ãã
greple --icode=utf8,euc-jp,shift-jis,7bit-jis
### add to guessing code set / èªåå¤å®ããã³ã¼ãã追å ãã
greple --icode=+euc-kr
---
## Filter / ãã£ã«ã¿ã¼
### expand tabs before seach / ã¿ããå±éãã¦ããæ¤ç´¢ãã
greple -n --if=expand
This match does not occur when option `--strict` is given, either.
## 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 ...
script/greple view on Meta::CPAN
}
## setup file encoding
if (@opt_icode) {
@opt_icode = map { split /[,\s]+/ } @opt_icode;
if (grep { s/^\+// } @opt_icode) {
unshift @opt_icode, @default_icode_list;
}
@opt_icode = uniq @opt_icode;
if (@opt_icode > 1) {
@opt_icode = grep { !/(?:auto|guess)$/i } @opt_icode;
Encode::Guess->set_suspects(@opt_icode);
$file_code = 'Guess';
}
elsif ($opt_icode[0] =~ /^(?:guess|auto)$/i) {
Encode::Guess->set_suspects(@default_icode_list);
$file_code = 'Guess';
} else {
$file_code = $opt_icode[0];
}
}
else {
$file_code = $default_icode;
}
script/greple view on Meta::CPAN
=over 7
=item B<--icode>=I<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 C<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 ...
t/15_encoding.t view on Meta::CPAN
use open IO => ':utf8';
use lib '.';
use t::Util;
$ENV{NO_COLOR} = 1;
like(run(q(--icode euc-jp ãã㯠t/SAMPLE_euc-jp.txt))->stdout,
qr/ããã¯/, "euc-jp");
like(run(q(--icode guess ãã㯠t/SAMPLE_euc-jp.txt))->stdout,
qr/ããã¯/, "guess euc");
like(run(q(--icode shift-jis ãã㯠t/SAMPLE_sjis.txt))->stdout,
qr/ããã¯/, "shift-jis");
like(run(q(--icode +shift-jis ãã㯠t/SAMPLE_sjis.txt))->stdout,
qr/ããã¯/, "guess shift-jis");
done_testing;
( run in 0.304 second using v1.01-cache-2.11-cpan-748bfb374f4 )