Subject: | "Modification of non-creatable hash value attempted" |
Date: | Fri, 29 Feb 2008 15:17:50 -0500 |
To: | bug-YAML-LibYAML [...] rt.cpan.org |
From: | Bernardo Rechea <brbpub [...] gmail.com> |
When Load'ing a YAML hash with a key whose value is undef, YAML::XS errors
with subject line message. YAML and YAML::Syck work. The code below
reproduces the problem.
=============================
#!/usr/bin/env perl
use 5.10.0;
use YAML::XS qw(Dump Load); # This errors
#use YAML qw(Dump Load); # This works
#use YAML::Syck qw(Dump Load); # This works
my $d = Load(<<EOY);
a: 2
b:
- 3
- asdf
c: ~
EOY
# Attempt to change the undef to a string blows up when using YAML::XS
$d->{c} = 'kk';
say Dump($d);
=============================
Interestingly, when the hash is dereferenced, it works:
=============================
#!/usr/bin/env perl
use 5.10.0;
use YAML::XS qw(Dump Load); # This errors
#use YAML qw(Dump Load); # This works
#use YAML::Syck qw(Dump Load); # This works
my %d = %{ Load(<<EOY) };
a: 2
b:
- 3
- asdf
c: ~
EOY
$d{c} = 'kk';
say Dump(\%d);
=============================