The first script loads and dumps YAML with a !!perl/hash:Foo tag:
use YAML;
use Data::Dumper;
my $yaml = <<"EOM";
--- !!perl/hash:Foo
b: B
a: A
EOM
my $data = Load $yaml;
say Dumper $data;
say Dump $data;
__END__
$VAR1 = bless( {
'b' => 'B',
'a' => 'A'
}, 'Foo' );
--- !!perl/hash:Foo
a: A
b: B
When using $YAML::Preserve, the dumped YAML is broken, the values of the hash are lost:
use YAML;
use Data::Dumper;
$YAML::Preserve = 1;
my $yaml = <<"EOM";
--- !!perl/hash:Foo
b: B
a: A
EOM
my $data = Load $yaml;
say Dumper $data;
say Dump $data;
__END__
$VAR1 = bless( {
'b' => 'B',
'a' => 'A'
}, 'Foo' );
--- !!perl/hash:Foo
a: ~
b: ~
While it may not be possible to preserve the key order of such objects, its contents shouldn't be lost, though.
The first script loads and dumps YAML with a
!!perl/hash:Foo
tag:When using
$YAML::Preserve
, the dumped YAML is broken, the values of the hash are lost:While it may not be possible to preserve the key order of such objects, its contents shouldn't be lost, though.