http://www.perlmonks.org?node_id=949179

silentius has asked for the wisdom of the Perl Monks concerning the following question:

Venerable Monks,

Please enlighten me, for I am in the dark even after a few hours reading the modules' documentation and experimenting.

I have this code:

while ($line = <IN>) { $strut = from_json($line); print Dumper($strut) . "\n"; }

The file I am reading from contains JSON records and is a text/plain; charset=utf-8 text file.

The problem is some records in that file have keys that have accented chars, namely "Particípio Passado" and when I output those records through the Data::Dumper module they come as:

"Partic\x{c3}\x{ad}pio Passado" => [ 'abasinado' ],

If I do a normal print of the keys, they come right, they come as "Particípio Passado", without the \x{c3}\x{ad} encoding.

Also, with this code: print $strut->{'Particípio Passado'}->[0]."\n"; I can access the records' contents, so the keys seem properly encoded.

But when I output through Data::Dumper they come as "Partic\x{c3}\x{ad}pio Passado", so, venerable monks, my question is: how do I make the records output through Data::Dumper come out as "Particípio Passado" instead of "Partic\x{c3}\x{ad}pio Passado"?

Gratefully, humbly and respectfully I appreciate and thank any enlightenment on this.