@kyanny's blog

My thoughts, my life. Views/opinions are my own.

2008-12-26から1日間の記事一覧

'\xf1\xd9' みたいな16進数文字列を変数展開?して「騙」って漢字にしたい

うまく説明できないけど、 #3. のブロックが pass して欲しい。 #!/usr/local/bin/perl # $Id$ use strict; use warnings; use Test::More; plan 'no_plan'; use Encode; my $kanji = '騙'; { #1. pass my $hex = "\xf1\xd9"; is $hex, to_euc($kanji); }; {…

Regexp::Log::Common の使い方を覚えた

これでもう access_log をパースするときに正規表現をどう書くべきかで悩む必要がなくなった。普通に LogFormat combined なファイルをパースするときはこれでいい。 my $foo = Regexp::Log::Common->new( format => ':extended', capture => [qw(host rfc a…

eshell のパイプ

eshell では input redirection が使えない (perl ./hoge.pl けどこれも厳密にはふつうの shell とはちょっと違うようだ。 #!/usr/local/bin/perl use strict; use Test::Simple tests => 1; ok -t STDIN; 1; こんなスクリプトを用意する。 pipe か input re…