App-Greple

 view release on metacpan or  search on metacpan

Example.md  view on Meta::CPAN

	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
	

README.md  view on Meta::CPAN

    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.565 second using v1.01-cache-2.11-cpan-702932259ff )