in reply to Re: How to get the Unicode of a character in perl?
in thread How to get the Unicode of a character in perl?

strangedoc wrote:
use strict; use warnings; use Data::Dumper; use Unicode::UCD qw' charinfo '; my $k = chr 12794; # http://en.wikipedia.org/wiki/Mu_%28kana%29 print Dumper( { ord => ord $k, chr => $k, charinfo => charinfo(ord $k), }), "\n"; __END__ $VAR1 = { 'charinfo' => { 'digit' => '', 'bidi' => 'L', 'category' => 'Lo', 'code' => '31FA', 'script' => 'Katakana', 'combining' => 0, 'upper' => '', 'name' => 'KATAKANA LETTER SMALL MU', 'unicode10' => '', 'decomposition' => '', 'comment' => '', 'mirrored' => 'N', 'lower' => '', 'numeric' => '', 'decimal' => '', 'title' => '', 'block' => 'Katakana Phonetic Extensions' }, 'chr' => "\x{31fa}", 'ord' => 12794 };

Just to demonstrate how much nicer to look at, and more convenient all around, that the CPAN Data::Dump module is for actually dumping out data than the woefully standard Data::Dumper module is, here is the same code written to use the other module:

#!/usr/bin/env perl use strict; use warnings; use Unicode::UCD qw(charinfo); use Data::Dump; my $k = chr 12794;  dd {     ord         =>          ord $k,     chr         =>              $k,     charinfo     => charinfo(ord $k), };

And here is the lovely output:

{   charinfo => {     bidi          => "L",     block         => "Katakana Phonetic Extensions",     category      => "Lo",     code          => "31FA",     combining     => 0,     comment       => "",     decimal       => "",     decomposition => "",     digit         => "",     lower         => "",     mirrored      => "N",     name          => "KATAKANA LETTER SMALL MU",     numeric       => "",     script        => "Katakana",     title         => "",     unicode10     => "",     upper         => "",   },   chr => "\x{31FA}",   ord => 12794, }

Isn’t that a lot easier on hand and eye?