App-Greple

 view release on metacpan or  search on metacpan

Example.md  view on Meta::CPAN

### list up all Japanese Katakana words / 片仮名の単語を全部抜き出す

	greple -ho --nocolor --join '\p{utf8::InKatakana}[\n\p{utf8::InKatakana}]*'

### you like it? / 気に入ったらこんな風にどうぞ

	cat >> ~/.greplerc
	define :kana: \p{utf8::InKatakana}
	option --kanalist --color=never --only-matching --join --re ':kana:[:kana:\n]+'

### find `cyclic redundancy c*`

	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
	
	# give better looking for tab indented text

### find from EXIF data / EXIF 情報を検索する

	greple --if='env LC_ALL=en_US exif -x /dev/stdin' 'Image_Description|Manufacturer' *.jpg

---
## Print Function / プリント関数

### Search iCal data / iCal のデータを検索する

    help   --ical Search iCal data
    option --ical \
            --all \
            --chdir ~/Library/Calendars/*.caldav/*.calendar/Events \
            --glob *.ics \
            --print print_ical_line
    
    __CODE__
    sub print_ical_line {
        s/\r//g;
        my $s = '';
        my(@s, @e);
        if (@s = /^DTSTART.*(\d{4})(\d\d)(\d\d)(?:T(\d\d)(\d\d))?/m) {
            $s .= "$1/$2/$3";
            $s .= " $4:$5" if defined $4;
        }
        if (@e = /^DTEND.*(\d{4})(\d\d)(\d\d)(?:T(\d\d)(\d\d))?/m) {
            if ($s[0]eq$e[0] and $s[1]eq$e[1] and $s[2]+1>=$e[2]) {
                $s .= "-$4:$5" if defined $4;
            } else {
                $s .= "-";
                $s .= "$1/" if $s[0] ne $e[0];
                $s .= "$2/$3";
            }
        }
        $s .= " ";
        /^SUMMARY:(.*)/m and $s .= $1;
        /^LOCATION:(.*)/m and $s .= " \@[$1]";
        $s .= "\n";
        $s;
    }



( run in 1.749 second using v1.01-cache-2.11-cpan-39bf76dae61 )