1YAML::PP::Schema::Tie::UIsxeHrasCho(n3t)ributed Perl DocYuAmMeLn:t:aPtPi:o:nSchema::Tie::IxHash(3)
2
3
4
6 YAML::PP::Schema::Tie::IxHash - (Deprecated) Schema for serializing
7 ordered hashes
8
10 use YAML::PP;
11 use Tie::IxHash;
12 my $yp = YAML::PP->new( schema => [qw/ + Tie::IxHash /] );
13
14 tie(my %ordered, 'Tie::IxHash');
15 %ordered = (
16 U => 2,
17 B => 52,
18 );
19
20 my $yaml = $yp->dump_string(\%ordered);
21
22
23 # Output:
24 ---
25 U: 2
26 B: 52
27
29 This is deprecated. See the new option "preserve" in YAML::PP.
30
31 This schema allows you to dump ordered hashes which are tied to
32 Tie::IxHash.
33
34 This code is pretty new and experimental.
35
36 It is not yet implemented for loading yet, so for now you have to tie
37 the hashes yourself.
38
39 Examples:
40
41 order
42 # Code
43 tie(my %order, 'Tie::IxHash');
44 %order = (
45 U => 2,
46 B => 52,
47 c => 64,
48 19 => 84,
49 Disco => 2000,
50 Year => 2525,
51 days_on_earth => 20_000,
52 );
53 \%order;
54
55
56 # YAML
57 ---
58 U: 2
59 B: 52
60 c: 64
61 19: 84
62 Disco: 2000
63 Year: 2525
64 days_on_earth: 20000
65
66 order_blessed
67 # Code
68 tie(my %order, 'Tie::IxHash');
69 %order = (
70 U => 2,
71 B => 52,
72 c => 64,
73 19 => 84,
74 Disco => 2000,
75 Year => 2525,
76 days_on_earth => 20_000,
77 );
78 bless \%order, 'Order';
79
80
81 # YAML
82 --- !perl/hash:Order
83 U: 2
84 B: 52
85 c: 64
86 19: 84
87 Disco: 2000
88 Year: 2525
89 days_on_earth: 20000
90
92 register
93 Called by YAML::PP::Schema
94
95
96
97perl v5.32.1 2021-01-27 YAML::PP::Schema::Tie::IxHash(3)