Data::Dumper でUTF-8文字列をエスケープしないようにする

こちらからの引用:
http://ido.nu/kuma/2006/09/12/avoiding-data-dumper-dumps-utf8-flagged-values-in-escaped-strings/

use Data::Dumper;
{
 package Data::Dumper;
 sub qquote { return shift; }
}
$Data::Dumper::Useperl = 1;

こっちの方がそれっぽいかも。

use Data::Dumper;
{
 package Data::Dumper;
 sub qquote { return wantarray? @_ : shift; }
}
$Data::Dumper::Useperl = 1;

さらにこんなのもあった:
http://blog.livedoor.jp/nipotan/archives/50228106.html

Unicode::RecursiveDowngrade
 

use strict;
use XML::Simple;
use Unicode::RecursiveDowngrade;
use Data::Dumper;

my $ref = XMLin('hoge.xml'); # includes flagged UTF-8
my $rd = Unicode::RecursiveDowngrade->new;
$ref = $rd->downgrade($ref); # unflagged UTF-8
print Dumper $ref;


Leave a Reply