Subject: | Values are decoded but the hash keys aren't when using ->fetchrow_hashref() |
I don't know what else can I provide to help debug this.
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw/:5.10/;
use DBI;
use Data::Dumper;
use Encode qw/is_utf8 decode/;
use utf8;
$Data::Dumper::Useqq = 1;
{
no warnings 'redefine';
sub Data::Dumper::qquote {
my $s = shift;
return "'$s'";
}
}
binmode STDOUT, ":utf8";
$ENV{NLS_LANG} = "Japanese_Japan.AL32UTF8";
my $dbh = DBI->connect("dbi:Oracle://1.1.1.1:1521/orcl", "DBUSER", "DBPASS") or die $@;
my $sth = $dbh->prepare(q|SELECT * FROM DFW_M20M WHERE "名称1" = '調達区分'|);
$sth->execute();
my $data = $sth->fetchrow_hashref;
for my $key ( keys %$data ) {
say "key (", (is_utf8($key) ? 1 : 0), "): ", $key;
say "decoded : ", decode("utf8", $key);
say "value(", (is_utf8($data->{$key}) ? 1 : 0), "): ", $data->{$key};
}
__DATA__
key (0): �称2
decoded : 名称2
value(1):
key (0): �称K2
decoded : 名称K2
value(1): 22
key (0): FILLER
decoded : FILLER
value(1):
key (0): �称K1
decoded : 名称K1
value(1): 00
key (0): �称1
decoded : 名称1
value(1): 調達区分