Skip to content

Instantly share code, notes, and snippets.

@sng2c
Created May 23, 2013 06:04
Show Gist options
  • Save sng2c/5633029 to your computer and use it in GitHub Desktop.
Save sng2c/5633029 to your computer and use it in GitHub Desktop.

source

#!/usr/bin/env perl 
use 5.010;
use utf8;
use Data::Dumper;
use Data::Dump;
use YAML;
use JSON;
use Data::Printer;

my $data = ['a',2,3,{name=>'한글테스트',num=>[4,5,6]}];

say "### Data::Dumper";
say Dumper $data;

say "### Data::Dump";
dd $data;

say "### YAML";
say Dump $data;

say "### JSON";
say encode_json $data;

say "### Data::Printer";
p $data;

output

### Data::Dumper
$VAR1 = [
          'a',
          2,
          3,
          {
            'num' => [
                       4,
                       5,
                       6
                     ],
            'name' => "\x{d55c}\x{ae00}\x{d14c}\x{c2a4}\x{d2b8}"
          }
        ];

### Data::Dump
[
  "a",
  2,
  3,
  {
    name => "\x{D55C}\x{AE00}\x{D14C}\x{C2A4}\x{D2B8}",
    num  => [4, 5, 6],
  },
]
### YAML
Wide character in say at dump.pl line 19.
---
- a
- 2
- 3
- name: 한글테스트
  num:
    - 4
    - 5
    - 6

### JSON
["a","2","3",{"num":["4","5","6"],"name":"한글테스트"}]
### Data::Printer
Wide character in print at /home/sng2c/perl5/perlbrew/perls/perl-5.18/lib/site_perl/5.18.0/Data/Printer.pm line 190.
\ [
    [0] "a",
    [1] 2,
    [2] 3,
    [3] {
        name   "한글테스트",
        num    [
            [0] 4,
            [1] 5,
            [2] 6
        ]
    }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment