■2009-05-12
    *   [Perl][メモ] TTのvmehtodの件
前書いたTemplate::Stash::XSのlengthの件、他にもUnicodeなハッシュキーを扱えないという問題もあったみたい(rt.cpan.org)。以下左記ページから:
 use strict;
 use warnings;
 use utf8;
 use Template;
 binmode STDOUT, ':utf8';
 
 # $Template::Config::STASH = 'Template::Stash';
 # ↑これをコメントアウトすれば適切な動作
 
 Template->new()->process(\*DATA, {
    ascii => 'key',
    utf8 => '鍵',
    hash => {
        key => 'value',
        鍵 => '値'
    },
    str => 'カワカマス'
 });
 
 __DATA__
 ascii = [% ascii %]
 hash.$ascii = [% hash.$ascii %]
 utf8 = [% utf8 %]
 hash.$utf8 = [% hash.$utf8 %]
 str.length = [% str.length %]
結果:
ascii = key hash.$ascii = value utf8 = 鍵 hash.$utf8 = str.length = 15
			[]
		
	
